Your problem does not match what should happen in practice. Your profile definition sounds about right to me:
mvn clean install
will enable the db-localhost-mysql
(as it is marked as to be activated by default) and it will add mysql-connector-java
. The same will happen if you run mvn clean install -Pdb-localhost-mysql
mvn clean install -Pdb-localhost-oracle
will add the ojdbc6
driver. The mysql profile will not be enabled (as it is triggered only if no profile is explicitly active).
That does not mean your current dependency hierarchy hasn't already one of those jars. It might come as a transitive dependency. To isolate this case and know which project needs to be fixed run mvn dependency:tree -Pdb-localhost-oracle
to look at your dependencies hierarchy when the mysql profile is not enabled.