Reputation: 4978
I Have started to learn on springs recently and I am stuck at the very beginning. in the tutorial that I follow on youtube it says that i have to install maven and from maven i can install spring, i have installed maven and now i want to install Spring framework from it. it sounds pretty simple. As i understand, maven searches for the spring framework from its repositories and downloads.
I have referred these two links - First and Second
But when i try to search for dependencies, i dont see any dependencies dispalyed to me when i search for "springframework" as shown in the tutorial.
everywhere i google, they say the maven indexes have to be updated on startup, the update process starts when i start eclipse , but its not finishing/ending.
This is my pom.xml file,
<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>com.caveofprogramming.spring.test</groupId>
<artifactId>testprog</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>testprog</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Upvotes: 0
Views: 6619
Reputation: 17
It's pretty simple. For starting out, your pom.xml file should have these directories (This is for maven):
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
and
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
and
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
these should be under the
so in the end your pom.xml should look like this:
<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>qwe</groupId>
<artifactId>qwe</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<testSourceDirectory>src/main/test</testSourceDirectory>
<resources>
<resource>
<directory>src/main/webapp</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
</plugin>
</plugins>
</build>
<dependencies><dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.7.RELEASE</version>
</dependency><dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.7.RELEASE</version>
</dependency></dependencies>
</project>
Subsequently you should right click your maven project > run > run as > maven install and it should install properly. email me at [email protected] if you have any questions.
Upvotes: 1
Reputation: 5897
Spring
is a huge framework and it depends which parts of it do you need. For example, for spring-context
specify the following dependency in pom.xml
:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
For spring-core
:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
For spring-web
:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
And so on. I recommend you to use Maven Repository where you can find any Spring
dependency you need. Some of the dependencies already include another, for example, with spring-mvc
you already get spring-core
, spring-context
, string-web
and some others.
So, try to add those dependencies and then execute the Maven
command:
mvn clean install
This should download all the dependencies and put them to your local repository. If this will not work, try to use -U
parameter like this
mvn clean install -U
Upvotes: 0
Reputation: 96
Try to add this to your dependencies:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
Upvotes: 1