Can I install the mysql jdbc connector using mvn install:install-file? - mysql

I'd like to install the JDBC connector using maven.
I have the following: mvn install:install-file -DgroupId=mysql -DartifactId=mysql-connnector-java -Dversion=5.1.6 -Dpackaging=jar -Dfile= -DgenerationPom=true
I think all I'm need is what I put on the other side of the =Dfile= ?
I haven't used maven in a while either, so I'm not sure what the file switch is used for?
Thanks for all the insight!

The "install-file" or "deploy-file" goals are used for installing or deploying artifacts to your local or internal repository that are not available from Maven Central or other external repositories that you may have configured.
If you've got access to Maven Central, simply adding the following to your project's pom.xml:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
...should do the trick.
To answer your question though, the -Dfile= argument is for specifying the artifact that would actually be installed in the local repository.

lotz answer is right and that should be sufficient
But, If you want to use the latest version of the connector, you can check https://mvnrepository.com/artifact/mysql/mysql-connector-java
Add the following to your project's pom.xml:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
</dependency>

Related

Maven error: Could not transfer artifact: ArtifactTransferException

I user Spring Tool Suite 4 to build a Spring boot project. When I try to specify dependency MySQL JDBC driver, I got this error:
Could not transfer artifact com.mysql:mysql-connector-j:jar:8.0.31 from/to central (https://repo.maven.apache.org/maven2): Connect timed out
org.eclipse.aether.transfer.ArtifactTransferException: Could not transfer artifact com.mysql:mysql-connector-j:jar:8.0.31 from/to central (https://repo.maven.apache.org/maven2): Connect timed out
The first I use these code:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
And after that I found this guide https://blogs.oracle.com/mysql/post/mysql-connectorj-has-new-maven-coordinates so I change to
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.0.31</version>
</dependency>
but it still does not work.
Please help me! It took me a lot of time.

geode-junit 1.8.0 pom depends on non-existent geode-old-versions artifact

I thought I might try out the GfshRule provided by geode-junit 1.8.0, but its pom contains a dependency on an apparently non-existent artifact called geode-old-versions so my Maven-based project won't build. Please advise. Thanks
<dependency>
<groupId>org.apache.geode</groupId>
<artifactId>geode-old-versions</artifactId>
<version>1.8.0</version>
<scope>runtime</scope>
</dependency>
This problem has been fixed in Geode 1.10.0, through GEODE-6105.
Cheers.

CXF Version of camel-cxf dependency

How I get the CXF version used on the follwowing maven dependency
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-cxf</artifactId>
<version>2.16.5</version>
</dependency>
I got it using maven dependences by click on the camel-cxf dependency in my project to open the camel-cxf pom then switched to 'Effective POM'. There you can search for cxf-core dependency and get the version.

Spring mysql-connector version incompatibility

i am coding a maven project with spring,
the default mysql-connector is version 6.0.5, and whenever i run the app on server the stack trace tells me that "Could not load JDBC driver class [com.mysql.jdbc.Driver]".
So i add as external library mysql-connector downloaded from mvnrepository.com version 5.1.40, add the dependency code to pom.xml and then it works!
How can i fix it using v 6.0.5?
thanks
If I understand you correctly you downloaded manually mysql connector, and added it as library.
Add dependency in pom.xml and reimport maven dependencies.
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.5</version>
</dependency>
You should checkout if your application.properties are set correctly, e.g:
spring.datasource.url=jdbc:mysql://localhost/jpa_example
spring.datasource.username=root
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect

Replace hsqldb with MySQL

I have a Spring REST project configured with hsqldb.
I would like to change it to MySQL.
I have MySQL server installed and running, but I don't know how to modify this pom:
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>runtime</scope>
</dependency>
PS.: Project im talking about comes as a source code for 'Spring REST' book:
http://www.apress.com/9781484208243
source code download link:
http://www.apress.com/downloadable/download/sample/sample_id/1704/
As far I see you are using Spring Boot on this, so you can easy change the databases changing the drivers dependencies from:
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>runtime</scope>
</dependency>
To
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
The driver version will be version on parent pom.
Then specify the parameters on properties
spring.datasource.url=jdbc:mysql://localhost:port/yourdb
spring.datasource.username=dbuser
spring.datasource.password=dbpass
spring.datasource.driver-class-name=com.mysql.jdbc.Driver # we can ommit this if we want, Spring Boot will deduce based on the classpath
For more configuration on databases you can see the properties available on appendix here