If you don't use Class.forName(...)
to load the driver manually, then I think you faced an infamous problem with maven-assembly-plugin
- it overwrites files with the same name when they come from different jar
s.
In your case JDBC driver discovery mechanism relies on a file named /META-INF/services/java.sql.Driver
, and you have at least two jar
s containing such a file in your dependencies (Oracle and Postgres drivers), therefore one of them is lost after running maven-assembly-plugin
.
You can use maven-shade-plugin
instead of maven-assembly-plugin
to merge these files correcly, as described here.
Alternatively, you can use Class.forName(...)
to sidestep the failing autodiscovery mechanism.