sometimes you know it, here you need to have the api and transaction for Connector and Transaction stuff.
In case of self build applications you should also know what you need.
In case of third party libs the vendor should declare the dependencies.
Also you will run into ClassNotFound Exceptions if a dependency is not declared.
Sometimes it's written in given libs docs.
Good way might be to check given project's maven artifact's pom.xml. Although these sometimes include optional sttuff without note.
Also, you can check includes in java files.
Fixing cnfex is always the last but certain fallback :)