Import and Dependency Management in Maven - java

I was learning about "import" scope in maven and did a sample project below,
Project_1 POM file :
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
project_2 POM file :
<parent>
<groupId>com.sample</groupId>
<artifactId>project1</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
...
...
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.sample</groupId>
<artifactId>project1</artifactId>
<version>1.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
However, this throws an error stating that the JUnit packages are not available in Project2. When I remove the dependencyManagement tag from project_1 POM file. Everything works fine.
But as per the maven docs,
This scope is only supported on a dependency of type pom in the
section. It indicates the dependency to be
replaced with the effective list of dependencies in the specified
POM's section. Since they are replaced,
dependencies with a scope of import do not actually participate in
limiting the transitivity of a dependency.
I've done as mentioned in the docs, what went wrong here?

It looks like you're trying to use a bill-of-materials (BOM) POM and import that.
Your Project_1 is the BOM POM in this case, and you include all your project's dependencies in the <dependencyManagement> element. It looks like you're doing this correctly.
To import a BOM POM in your project however, you need both <dependencyManagement> and <dependencies>.
For example, your Project_2 pom.xml should include:
<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.sample</groupId>
<artifactId>project1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencyManagement>
<dependencies>
<!-- Imports the bill-of-materials POM. -->
<dependency>
<groupId>com.sample</groupId>
<artifactId>bom</artifactId>
<version>1.0-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Add a dependency from the BOM POM.
Note: no version or scope is required, it's inherited from the BOM POM! -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
</project>
Here is the BOM POM definition for the above 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.sample</groupId>
<artifactId>bom</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
There is documentation about this on the Apache Maven website (search for "bom").
Update:
BOM POMs and parent POMs are similar but different. BOM POMs are meant purely for importing dependencies into your project. Parent POMs are meant for multi-module projects, and allow you to define Maven coordinates, plugins, and dependencies that will be inherited by all of modules using the parent POM.
Here is an example of using an inherited dependency from a parent POM. Note that there are several elements included here that don't make sense in a BOM POM.
<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>
<parent>
<groupId>com.sample</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>project1</artifactId>
<packaging>jar</packaging>
<dependencies>
<!-- Inherited from the parent POM. -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
</project>
Here is the parent POM definition for the above 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.sample</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>child1</module>
<module>child2</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!--Global dependencies...-->
</dependencies>
<build>
<pluginManagement>
<!--Plugins...-->
</pluginManagement>
</build>
</project>

First Make sure you are using Maven version 2.0.9 or later that supports this functionality.
Second your Project1 Pom.Xml is missing the attribute "packaging" Make sure your packaging and type are of the same name so that it inherits all the dependencies.
Also your artifact Id and group ID has to be the same as your project 1's Pom.xml file for it to import the dependency
When in doubt refer to this link
https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies

Related

Maven cyclic dependency

my maven project has multiple maven modules. Two of those modules (product and feature) are dependent on each other. When I include the modules as dependencies in the pom files, an ! mark appears on the modules. On running maven install I get this error.
The projects in the reactor contain a cyclic reference: Edge between
'Vertex{label='com.catalog:feature:0.0.1-SNAPSHOT'}' and
'Vertex{label='com.catalog:product:0.0.1-SNAPSHOT'}' introduces to
cycle in the graph com.catalog:product:0.0.1-SNAPSHOT -->
com.catalog:feature:0.0.1-SNAPSHOT --> com.catalog:product:0.0.1-
SNAPSHOT #
Without adding the dependencies Product can't access functions defined in Feature module and vice versa.
The parent pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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.catalog</groupId>
<artifactId>catalog</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.1-api</artifactId>
<version>1.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.enterprise</artifactId>
<version>4.2.0</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.0.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.4.1.Final</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.6</version>
</dependency>
</dependencies>
<modules>
<module>category</module>
<module>resource</module>
<module>hibernate</module>
<module>product</module>
<module>helper</module>
<module>feature</module>
</modules>
Product module pom.xml
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.catalog</groupId>
<artifactId>catalog</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>product</artifactId>
<name>product</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.catalog</groupId>
<artifactId>hibernate</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.catalog</groupId>
<artifactId>category</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.catalog</groupId>
<artifactId>helper</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.catalog</groupId>
<artifactId>feature</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Feature module pom.xml
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.catalog</groupId>
<artifactId>catalog</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.catalog</groupId>
<artifactId>feature</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>feature</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.catalog</groupId>
<artifactId>hibernate</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.catalog</groupId>
<artifactId>product</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
</project>
Design smell.
Refactor your modules. Basically everything which is needed in both modules should go into a common dependency. You cannot have cycles in your dependency tree, it just won't work.
Update: As this answer is occasionally getting a new upvote, I wanted to mention: the "tree" in "dependency tree" refers to a tree from graph theory, which means that by definition you cannot have cycles :)
It may not work for your particular situation but another option to rectify cyclical dependencies is to use events.
First, set your modules up in a tree with no cyclical dependencies. Put your Event classes at the top of the tree. Then publish and listen for events in any of the modules. This allows you to have modules that communicate with each other without depending on each other.
For how to publish and listen for events in Spring see:
https://spring.io/blog/2015/02/11/better-application-events-in-spring-framework-4-2

Why is my Maven not using the defined BOM?

I am currently trying to introduce a BOM (bill of materials) file to my Maven project, but it does not seem to work and I have no clue, why.
This is my bom:
<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.private</groupId>
<artifactId>test.bom</artifactId>
<version>5.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<version.CoreAnnotation>5.0.0-SNAPSHOT</version.CoreAnnotation>
<version.CoreWeb>5.0.0-SNAPSHOT</version.CoreWeb>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.private</groupId>
<artifactId>CoreAnnotation</artifactId>
<version> ${version.CoreAnnotation}</version>
<type>ejb</type>
</dependency>
<dependency>
<groupId>com.private</groupId>
<artifactId>CoreWeb</artifactId>
<version>${version.CoreWeb}</version>
<type>war</type>
</dependency>
</dependencies>
</dependencyManagement>
</project>
There are many more, but I excluded them because I think this should be enough as an example.
This is my pom (where I try to include the bom):
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<artifactId>Core</artifactId>
<groupId>com.private</groupId>
<version>5.0.0-SNAPSHOT</version>
</parent>
<artifactId>Core-ear</artifactId>
<packaging>ear</packaging>
<name>Core-ear: EAR Module for private</name>
<properties>
<version.test.bom>5.0.0-SNAPSHOT</version.test.bom>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.private</groupId>
<artifactId>test.bom</artifactId>
<version>${version.test.bom}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>
Whenever I use maven install there should be a collection of all packages defined in the dependencies section appear in the folder \target\Core-ear\
Now the problem: The dependencies defined in the bom don't appear there. What could be the problem?
ps: running mvn install -X for debugging does not seem to help.
This happens because you did not declare the dependencies in your POM. You only declared the <dependencyManagement> section.
In your POM, you need to add the following dependencies, without the version:
<dependencies>
<dependency>
<groupId>com.private</groupId>
<artifactId>CoreAnnotation</artifactId>
<type>ejb</type>
</dependency>
<dependency>
<groupId>com.private</groupId>
<artifactId>CoreWeb</artifactId>
<type>war</type>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.private</groupId>
<artifactId>test.bom</artifactId>
<version>${version.test.bom}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Refer to Introduction to the Dependency Mechanism: BOM are used to factor version of all the artifacts, so you don't need to add it in your <dependency> section.

maven multi-module project with jersey & spring

I've been referring stackoverflow questions for quite some time. now i have got one of my own. I'm basically trying to create a Rest webservice with Jersey 2.22.1. I'm using this archetype to create a maven jersey project from section 1.4 here
mvn archetype:generate -DarchetypeArtifactId=jersey-quickstart-webapp \
-DarchetypeGroupId=org.glassfish.jersey.archetypes -DinteractiveMode=false \
-DgroupId=com.example -DartifactId=simple-service-webapp -Dpackage=com.example \
-DarchetypeVersion=2.22.1
This generates a sample rest jersey webservice. Now i want to access mongodb through this webservice. I'm trying to create a separate jar maven project that uses spring to connect to mongodb. its structure is
com.yuvi.mongo.service
com.yuvi.mongo.dao
I have a main class inside service which loads spring context , retrieve dao bean n performs db access.
Now i want to connect these two projects.
I created a parent project, included these 2 as its modules and added mongo as dependency in service. but when i try to access package com.yuvi.mongo from my service it shows package not found error. I created two simple maven projects and followed same procedure for creating multi-module projects that was working perfectly. but when i try it here i can't access the package. I'm displaying my pom files here.,
parent pom
<?xml version="1.0" encoding="UTF-8"?>
<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.yuvi</groupId>
<artifactId>Parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>Mongo</module>
<module>RService</module>
</modules>
</project>
Mongo pom
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.yuvi</groupId>
<artifactId>Parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.yuvi.mongo</groupId>
<artifactId>Mongo</artifactId>
<name>Mongo</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-version>4.2.3.RELEASE</spring-version>
<mongodb-version>1.8.1.RELEASE</mongodb-version>
</properties>
<dependencies>
<!-- Spring 4 dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-mongodb</artifactId>
<version>${mongodb-version}</version>
</dependency>
</dependencies>
</project>
RService pom
<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>
<parent>
<groupId>com.yuvi</groupId>
<artifactId>Parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>com.yuvi.service</groupId>
<artifactId>RService</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>RService</name>
<build>
<finalName>RService</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<inherited>true</inherited>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.yuvi.mongo</groupId>
<artifactId>Mongo</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.glassfish.jersey</groupId>
<artifactId>jersey-bom</artifactId>
<version>${jersey.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<!-- use the following artifactId if you don't need servlet 2.x compatibility -->
<!-- artifactId>jersey-container-servlet</artifactId -->
</dependency>
<!-- uncomment this to get JSON support
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-moxy</artifactId>
</dependency>
-->
</dependencies>
<properties>
<jersey.version>2.22.1</jersey.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
</project>

Managing Spring Boot parent POM version in multiple projects

I've created a few Spring Boot projects, each one's POM including a spring-boot-starter-parent as a parent. Whenever a new version comes out, I currently need to manually update it in every POM.
Adding a POM dependency which already has the spring-boot-starter-parent does not help, and the Spring Boot documentation states that using an 'import' scope will only work for dependencies, and not the Spring Boot version itself.
Is there a way to define a "super-pom" which all my projects can inherit from, where I can set the Spring Boot version once, and not go through each project?
Here is an approach you can try.
Your parent POM:
<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>
<!-- Do you really need to have this parent? -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.7.RELEASE</version>
</parent>
<groupId>org.example</groupId>
<artifactId>my-parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Parent POM</name>
<properties>
<!-- Change this property to switch Spring Boot version-->
<spring.boot.version>1.2.7.RELEASE</spring.boot.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Declare the Spring Boot dependencies you need here
Please note that you don't need to declare the version tags.
That's the whole point of the import above.
-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
</dependency>
<!-- About 50 in total if you need them all -->
...
</dependencies>
</project>
A child POM:
<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>
<parent>
<groupId>org.example</groupId>
<artifactId>my-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>my-child</artifactId>
<name>Child POM</name>
</project>
If you do a mvn dependency:tree on the child POM, you'll see that they are all in there.

failed to read artifact

i want add org.springframework.spring.web-mvc3.2.0.RELEASE dependency in my project . but when i add this dependency and save that , it show this error :
and pom.xml :
<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>fit</groupId>
<artifactId>Example01</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Example01 Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.2.0.RELEASE</version>
</dependency>
</dependencies>
<build>
<finalName>Example01</finalName>
</build>
</project>
It seems that you lost the connection to Maven central half way during the transfer. The problem is that your artifacts could become out of sync with Maven cache. If your local Maven repository is relatively small I would suggest to delete entire repository folder under .m2 and try to rebuild again from the command line (mvn clean install)

Categories

Resources