Reputation: 11420
I'm new to Maven and Eclipse. We have been using Netbeans and installing jars manually in our projects.
I thought the purpose of Maven was to download the required jars based on your dependencies?
In a new project, I added the following under my dependencies
node of my pom.xml file:
<!-- Java dependencies -->
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>com.springsource.javax.annotation</artifactId>
</dependency>
<!-- Spring dependencies -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>org.springframework.orm</artifactId>
</dependency>
<!-- Spring Security dependencies -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>org.springframework.security.config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>org.springframework.security.core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>org.springframework.security.taglibs</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>org.springframework.security.web</artifactId>
</dependency>
<!-- Other dependencies -->
<dependency>
<groupId>com.mysql.jdbc</groupId>
<artifactId>com.springsource.com.mysql.jdbc</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>com.springsource.org.apache.commons.dbcp</artifactId>
<scope>runtime</scope>
</dependency>
But all I get is:
Project build error: 'dependencies.dependency.version' for javax.annotation:com.springsource.javax.annotation:jar is missing.
....
What am I doing wrong?
Upvotes: 4
Views: 2498
Reputation: 624
Dependency blocks almost always need a version number. If you search for your dependencies on http://search.maven.org/, you should be able to navigate to a page about the dependency with a complete dependency block.
For example, the page for Spring Security is:
The dependency block for it looks like:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-aspects</artifactId>
<version>3.1.0.RELEASE</version>
</dependency>
Upvotes: 7
Reputation: 3858
You need to provide more details for the other than just the groupId and artifactId to add a dependency to the pom.xml file.
Please look at this reference to understand how to add dependencies to the pom.xml file - http://maven.apache.org/pom.html#Dependencies
Upvotes: 1
Reputation: 642
As the error message points out, you're missing the <version>
child element for all of your <dependency>
elements.
If you browse for your dependencies on http://mvnrepository.com, it should be easy to find an example <dependency>
element that you can paste into your POM file, like this:
<dependency>
<groupId>springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>1.2.6</version>
</dependency>
Upvotes: 1
Reputation: 4886
as the error says the version attribute of the dependency is missing for the dependency entries in the pom.
notice how pom has been arranged in this example. http://www.mkyong.com/spring-security/spring-security-hello-world-example/
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
can be hard coded or can be added as a property as well. hope this helps
Upvotes: 2
Reputation: 81907
You need to specify the version of your dependencies like so:
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>com.springsource.javax.annotation</artifactId>
<version>1.0.0</version>
</dependency>
Upvotes: 3