如何让 Eclipse 和 Maven 下载我需要的 JAR?

2024-03-02

我是 Maven 和 Eclipse 的新手。我们一直在项目中使用 Netbeans 并手动安装 jar。

我以为Maven的目的是根据你的依赖关系下载所需的jar?

在一个新项目中,我在我的项目下添加了以下内容dependencies我的 pom.xml 文件的节点:

    <!-- 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>

但我得到的只是:

项目构建错误:javax.annotation:com.springsource.javax.annotation:jar 的“dependency.dependency.version”缺失。

....

我究竟做错了什么?


依赖块几乎总是需要版本号。如果您搜索依赖项http://search.maven.org/ http://search.maven.org/,您应该能够导航到具有完整依赖项块的有关依赖项的页面。

例如,Spring Security 的页面是:

http://search.maven.org/#artifactdetails|org.springframework.security|spring-security-aspects|3.1.0.RELEASE|jar http://search.maven.org/#artifactdetails%7Corg.springframework.security%7Cspring-security-aspects%7C3.1.0.RELEASE%7Cjar

它的依赖块如下所示:

<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-aspects</artifactId>
    <version>3.1.0.RELEASE</version>
</dependency>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何让 Eclipse 和 Maven 下载我需要的 JAR? 的相关文章

随机推荐