Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get Eclipse and Maven to download the JARs I need?

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?

like image 621
cbmeeks Avatar asked Dec 09 '22 23:12

cbmeeks


1 Answers

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:

http://search.maven.org/#artifactdetails|org.springframework.security|spring-security-aspects|3.1.0.RELEASE|jar

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>
like image 124
mawcsco Avatar answered Dec 28 '22 13:12

mawcsco