I am using Maven repository, I am trying to connect my application with MySQL database. I have added the required jar file as Maven dependency in my project.
I am able to build the project successfully but when I run the project it gives classNotFoundException.
I have added the jar location in CLASSPATH.
Gerold Broser is correct on top of that version it should be 5.1.37 not 5.1.37-bin
In maven this is the dependency :
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.37</version>
</dependency>
According to Maven Central the <groupId> for mysql-connector-java ist just mysql, not mysql-connector-java.
As mentioned in soorapadman's answer the (older) <version> is 5.1.37, not 5.1.37-bin, the latest is 6.0.3.
Additional hint: You don't have to declare <packaging>jar and <scope>compile explicitely, since these are the defaults anyway. (Remember Maven's core concept Convention over configuration.)
Related
Missing artifact com.oracle:ojdbc6:jar:11.1.0.7.0
I am using Spring tool suite IDE for developing spring maven project which is similar ecllipse IDE, I found Solutions for this issue on stackoverflow but it doesn't work for me'.
I tried two links:
Missing artifact com.oracle:ojdbc6:jar:11.2.0.3,
Oracle JDBC ojdbc6 Jar as a Maven Dependency
but still I am getting
Missing artifact com.oracle:ojdbc6:jar:11.1.0.7.0
error in pom.xml, I am now stuck at this point.
its because of ojdbc jar is not available on maven repo. so you have to add this dependency from local relative path
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.1.0.7</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/ojdbc6.jar</systemPath>
</dependency>
You can download ojdbc jar from http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html
I am nor able to run my eclipse maven project. I keep getting the following error in the problems tab
Archive for required library: 'C:/Users/user/.m2/repository/mysql/mysql-connector-java/5.1.38/mysql-connector-java-5.1.38.jar' in project 'Inspirations' cannot be read or is not a valid ZIP file
In my pom.xml file I have defined the dependency as
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>
You can try delete mysql folder in your repository and go to eclipse -> Maven --> Update Project.
If not working, i thinh u can try another version.
Ive included following lines in my pom.xml
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.6.RELEASE</version>
</dependency>
The specific spring-core JAR version I want is 4.1.6, but whenever I do an mvn clean install, the dependencies folder under my project in netbeans shows a downgraded version (currently 3.0.7.RELEASE).
I want to know how I can force maven to put 4.1.6.RELEASE jar in my dependencies folder. I've done
mvn dependency:purge-local-repository -DactTransitively=false -DreResolve=false
And I've the folder 4.1.6.RELEASE with correct jar in my local /.m2/repositories folder. I need to access org.springframework.util.MimeType class which is not available in spring-core 3.0.7.RELEASE jar.
See the result of mvn dependency:tree to know if another jar bring back the version 3.0.7. and exclude from this dependency the spring-core
See the same result to know if the right version is present
Add the pom.xml and the result of mvn dependency:tree in the question
Please follow these steps:
Check in .m2 local repository where the Spring 3.0.7 jar is downloaded(It should be under folder org->springframework)
Delete the folder present inside springframework, so that mvn will try to fetch required dependencies.
Let me know if it helps
The issue is that spring-core is a mandatory dependenecy of most spring artifacts. Most likely you are using a dependent artifact e.g spring-context which is of version 3.0.7. Then Maven is fetching spring-core of the same version as the dependent artifact using its transitive dependency mechanism.
To control the version of spring-core you need to move its declaration from the dependencies section to the dependency management section of your pom.xml as follows
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.1.6</version>
</dependency>
</dependencies>
</dependencyManagement>
I'm creating a program that uses spark and jetty libraries. The dependencies are managed by maven.
The problem is that some Classes are not found if bot dependencies are defined. Specifically org.eclipse.jetty.server.ServerConnector. There are no problems with other classes. If I remove the spark-core dependency, all work correctly. Why can this happen?
My example is based on this repository and the error can be reproduced adding the spark-core dependency to the "javax.websocket-example" project
I have tried with different versions of spark-core and jetty- websocket:
spark-core (2.10 and 2.11): 1.2.0 and 1.2.1
Javax.websocket-example: 9.3.0.M1, 9.2.7.v20150116 and 9.1.5.v9.1.5.v20140505
Maven dependences:
<dependency> <!-- Spark dependency -->
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>1.2.0</version>
<!--<scope>provided</scope>-->
</dependency>
<dependency> <!-- Jetty dependency -->
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>javax-websocket-server-impl</artifactId>
<version>9.2.7.v20150116</version>
<!--<scope>provided</scope>-->
</dependency>
EDIT:
More information: I have reproduced the error in an empty scenario using vagrant. The box used is this. I have installed maven, git and oracle Java using this manual. I have done the test with "javax.websocket-example" project of this repository.
In this test, the project runs without de spark-core dependency and it doesn't run with the dependence. The version used of the dependency is the last, and I have tried with the project jetty version and with the last of the 9.2.X (9.2.7.v20150116)
DEPENDECIES:
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.10</artifactId>
<version>1.2.1</version>
</dependency>
This is a dependency problem between the same library with different versions. (spark uses 8.1.XXX and my module uses 9.XX). The dependency cannot be excluded because is used in the modules. Then, this problem is a Java dependency problem and there is not solution without other technologies like OSGi
I Asked similar question here
My maven project uses Directory API Client Library for Java and i needed to include it as a dependency. But in Directory API Client Library for Java page, under the Add Library to Your Project title when i select maven as my build environment it always showed,
"Add the following to your pom.xml file:
This library is in the process of uploading to the central Maven repository. Please check back in a few hours."
for last couple of weeks.
Since i have used google drive dependency in another project as follows,
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-drive</artifactId>
<version>v2-rev60-1.13.2-beta</version>
</dependency>
I tried to so the same by including,
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-directory</artifactId>
<version>v1-rev28-1.17.0-rc</version>
</dependency>
but it didn't worked.
And for the recode my pom having following repository as well,
<repository>
<id>google-api-services</id>
<url>http://google-api-client-libraries.appspot.com/mavenrepo</url>
</repository>
What is the correct maven dependency to use Directory API Client Library for Java.
At the bottom of the page, there is a link as follows,
See all versions available on the Maven Central Repository.
I have went through that page and found a previous version of Directory API Client Library for Java. By looking at it's pom i have tried following dependency and it worked.
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-admin</artifactId>
<version>directory_v1-rev22-1.16.0-rc</version>
</dependency>
Then I tried to update the version to latest as follows and also worked.
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-admin</artifactId>
<version>directory_v1-rev28-1.17.0-rc</version>
</dependency>