如何让Eclipse和Maven下载我需要的JAR? [英] How do I get Eclipse and Maven to download the JARs I need?
问题描述
我认为Maven的目的是根据您的依赖关系下载所需的jar?
在一个新项目中,我在我的pom.xml文件的依赖项
节点下添加了以下内容:
<! - Java依赖关系 - >
<依赖关系>
< groupId> javax.annotation< / groupId>
< artifactId> com.springsource.javax.annotation< / artifactId>
< / dependency>
<! - Spring依赖关系 - >
<依赖关系>
< groupId> org.springframework< / groupId>
< artifactId> org.springframework.orm< / artifactId>
< / dependency>
<! - Spring安全性依赖关系 - >
<依赖关系>
< groupId> org.springframework.security< / groupId>
< artifactId> org.springframework.security.config< / artifactId>
< / dependency>
<依赖关系>
< groupId> org.springframework.security< / groupId>
< artifactId> org.springframework.security.core< / artifactId>
< / dependency>
<依赖关系>
< groupId> org.springframework.security< / groupId>
< artifactId> org.springframework.security.taglibs< / artifactId>
< / dependency>
<依赖关系>
< groupId> org.springframework.security< / groupId>
< artifactId> org.springframework.security.web< / artifactId>
< / dependency>
<! - 其他依赖关系 - >
<依赖关系>
< groupId> com.mysql.jdbc< / groupId>
< artifactId> com.springsource.com.mysql.jdbc< / artifactId>
< scope>运行时< / scope>
< / dependency>
<依赖关系>
< groupId> org.apache.commons< / groupId>
< artifactId> com.springsource.org.apache.commons.dbcp< / artifactId>
< scope>运行时< / scope>
< / dependency>
但我所得到的是:
项目构建错误:javax.annotation的dependencies.dependency.version:com.springsource.javax.annotation:jar缺少。
....
我做错了什么?
依赖块几乎总是需要一个版本号。如果您在 http://search.maven.org/ 上搜索您的依赖项,您应该可以浏览关于使用完整的依赖关系的依赖关系的页面。
例如,Spring Security的页面是:
依赖关系块它看起来像:
<依赖关系>
< groupId> org.springframework.security< / groupId>
< artifactId> spring-security-aspects< / artifactId>
< version> 3.1.0.RELEASE< / version>
< / dependency>
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?
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>
这篇关于如何让Eclipse和Maven下载我需要的JAR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!