I have a Java app based on Maven, and want to connect to MySQL server.
My pom has:
mysql
&l
Change the scope to compile
:
mysql
mysql-connector-java
5.1.17
jar
compile
Which - since it is the default scope corresponds to leaving away scope definition at all - same counts for the type:
mysql
mysql-connector-java
5.1.17
Have a look at this: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html for detailed information on scoping.
Here is a quick info for your background:
You specified the JDBC driver to have a scope runtime
. Most IDEs will anyways ignore the scopes and add all of your dependencies to their classpath (e.g. the classpath used when you run something outside of eclipse. By the scope runtime
you are telling maven that it must not pack that dependeny into your final jar since the execution environment will "provide that dependency at runtime
. E.g. you would either have to manually add it to the classpath when calling your jar or change the scope to compile
which will lead to the driver-jar beeing packed inside your jar and available at runtime.