gudii9
asked on
maven not picking latest jar instead picking old jar from .m2
Hi,
I am trying simple spring examples like hello world
I see maven not picking latest jars like spring core (4.1.6)instead picking old jar(3.0.5) from .m2.
How to tell maven to take latest but not old jar. I wonder why it is taking old jars. Please advise
mavenjars.png
mavenjars2.png
mavenjars3.png
mavenjars4.png
mavenjars5.png
I am trying simple spring examples like hello world
I see maven not picking latest jars like spring core (4.1.6)instead picking old jar(3.0.5) from .m2.
How to tell maven to take latest but not old jar. I wonder why it is taking old jars. Please advise
mavenjars.png
mavenjars2.png
mavenjars3.png
mavenjars4.png
mavenjars5.png
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Does your project build correctly with the 4.1.6 dependency in the pom file? If so, then I think that something is broken with your Eclipse because it should definitely list the 4.1.6 version as a possibility in the tree listing in the lower part of that window.
Anyway, it is not a big deal. All this is just a convenience to allow you to add dependencies. Just manually enter the version that you want into your pom file and your done.
Anyway, it is not a big deal. All this is just a convenience to allow you to add dependencies. Just manually enter the version that you want into your pom file and your done.
ASKER
Does your project build correctly with the 4.1.6 dependency in the pom file? If so, then I think that something is broken with your Eclipse because it should definitely list the 4.1.6 version as a possibility in the tree listing in the lower part of that windowit worked and got successful output.
How do i know if it took 4.1.6 or 3.0.5 jar internally?
eclipise and amven keeping all the things under the hood and hard to debug or see what is going behind the scenes
The pom.xml file is THE official source. If it is 4.1.6 in the pom.xml file then that IS the one that it will be using.
To double check, in the main screen that lists all the files/things in your project (Project Explorer), under your project there should be an item called "Maven Dependencies", and then if you look under that, you should find a .jar file with the name "spring-core-4.1.6.RELEASE .jar"
To double check, in the main screen that lists all the files/things in your project (Project Explorer), under your project there should be an item called "Maven Dependencies", and then if you look under that, you should find a .jar file with the name "spring-core-4.1.6.RELEASE
ASKER
sure let me double check there
ASKER
i checked my pom.xml
it is as below
i do not have any dependencies for any jars in that pom.xml. I am trying to add those jars like spring-core, spring-context etc bare minimum jars to make my spring application run.
While adding only it shows old jar that is the problem
it is as below
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>co.edureka.spring</groupId>
<artifactId>HelloSpring</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>co.edureka.spring</groupId>
<artifactId>HelloSpring</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
i do not have any dependencies for any jars in that pom.xml. I am trying to add those jars like spring-core, spring-context etc bare minimum jars to make my spring application run.
While adding only it shows old jar that is the problem
ASKER
here is the attachment again
mavenjars.png
mavenjars.png
ASKER
To double check, in the main screen that lists all the files/things in your project (Project Explorer), under your project there should be an item called "Maven Dependencies", and then if you look under that, you should find a .jar file with the name "spring-core-4.1.6.RELEASE.jar"
i checked other working project which has pom.xml as below (this example i downloaded from below link)
https://www.mkyong.com/spring3/spring-3-hello-world-example/
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mkyong.core</groupId>
<artifactId>Spring3Example</artifact Id>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Spring3Example</name>
<url>http://maven.apache.org</url>
<properties>
<spring.version>3.0.5.RELEASE</sprin g.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<!-- Spring 3 dependencies -->
<dependency>
<groupId>org.springframework</groupI d>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupI d>
<artifactId>spring-context</artifact Id>
<version>${spring.version}</version>
</dependency>
</dependencies>
</project>
MAven dependencies show spring-core-3.0.5-Release.
i wonder where that is coming from?
mavenDependencies.png
ASKER
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mkyong.core</groupId>
<artifactId>Spring3Example</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>Spring3Example</name>
<url>http://maven.apache.org</url>
<properties>
<spring.version>4.1.6.RELEASE</spring.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<!-- Spring 3 dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
</dependencies>
</project>
i changed pom as above to 4.1.6 release and as soon as i save my jars updated to 4.1.6 as attached
mavenDependencies2.png
ASKER
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
i do not have above spring-beans dependency in pom.xml right? but how the Maven Dependecies got spring-beans-4.1.6.jar?
Dependencies can include other dependencies. So either spring-core or spring-context (or both) include spring-beans. They call these "transitive dependencies"
ASKER
my .2 has only spring-core release 4.1.6 (not spring-core release 3.0.5)
not sure why eclipse suggested a library of older version which is not in my .m2 folder?
please advise
even my pom.xml also i gave dependency for 4.1.6 not 3.0.5??