在集成eclipse和maven时获取错误

时间:2013-05-06 16:35:17

标签: eclipse maven-2

我是maven和eclipse配置的新手。我在eclipse中设置了我的maven路径

enter image description here

然后我在eclipse中进行了项目运行配置

enter image description here

这是我的pom.xml的片段

<modelVersion>4.0.0</modelVersion>
<groupId>package</groupId>
<artifactId>myProject</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>myProject</name>
<url>http://maven.apache.org</url>

现在,当我调试我的项目时,我收到一个错误

Some problems were encountered while building the effective model for 
package:war:1.0-SNAPSHOT [WARNING] 
'build.plugins.plugin.version' for 
org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 189, column 15

在我的pom.xml文件中,我有一个像这样的条目

<build>
<plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
      <source>1.6</source>
      <target>1.6</target>
    </configuration>
  </plugin>
</plugins>

我也得到错误

Failed to execute goal on project myProject: Could not resolve dependencies for 
project pk.training.basitMahmood:myProject:war:1.0-SNAPSHOT: Failed to 
collect dependencies for [junit:junit:jar:4.4 (test), 
org.mockito:mockito-all:jar:1.8.1 (test), 
javax.servlet:servlet-api:jar:2.5 (compile), 
commons-lang:commons-lang:jar:2.5 (compile), 
org.apache.ant:ant-apache-log4j:jar:1.8.0 (compile), 
velocity-tools:velocity-tools:jar:1.4 (compile), 
org.springframework:spring-core:jar:2.5.5 (compile), 
org.springframework:spring-webmvc:jar:2.5.5 (compile), 
org.springframework:spring:jar:2.5.5 (compile), 
org.springframework:spring-test:jar:2.5.5 (compile), 
org.springframework.ws:spring-oxm:jar:1.5.5 (compile), 
org.springframework.ws:spring-oxm-tiger:jar:1.5.6 (compile), 
org.springframework.ws:spring-ws-core:jar:1.5.6 (compile), 
org.springframework.ws:spring-ws-core-tiger:jar:1.5.6 (compile), 
org.springframework.ws:spring-ws-security:jar:1.5.6 (compile), 
org.apache.velocity:velocity:jar:1.6.3 (compile), 
commons-digester:commons-digester:jar:1.8 (compile), 
ant:ant-jakarta-regexp:jar:1.6.1 (compile), 
org.json:json:jar:20090211 (compile),
com.xmlparserv2:LS360_xml_parser:jar:20110919 (compile), 
360_Oracle:toplink:jar:10.1.5 (compile), 
360_MS_SQL:sqlserver:jar:1.0 (compile), 
org.springframework.ws:spring-ws:jar:all:1.5.6 (compile)]:
Failed to read artifact descriptor for velocity-tools:velocity-tools:jar:1.4: 
Could not transfer artifact velocity-tools:velocity-tools:pom:1.4 from/to 
maven2-repository.jboss.com (http://repository.jboss.com/maven2): 
Access denied to 
http://repository.jboss.com/maven2/velocity-tools/velocity-tools/1.4/
velocity-tools-1.4.pom. Error code 403, Forbidden -> [Help 1]

但是我的pom.xml中有所有这些依赖项,比如

<dependencies>
<dependency>
  <groupId>junit</groupId>
  <artifactId>junit</artifactId>
  <version>4.4</version>
  <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-all</artifactId>
    <version>1.8.1</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>servlet-api</artifactId>
    <version>2.5</version>
    <type>jar</type>
    <scope>compile</scope>
</dependency>
<dependency>
    <groupId>commons-lang</groupId>
    <artifactId>commons-lang</artifactId>
    <version>2.5</version>
    <type>jar</type>
    <scope>compile</scope>
</dependency>
.....
</dependencies>

以下是存储库

<repositories>
    <repository>
        <id>maven2-repository.dev.java.net</id>
        <url>http://download.java.net/maven/2</url>
    </repository>
    <repository>
        <id>maven-repository.dev.java.net</id>
        <url>http://download.java.net/maven/1</url>
    </repository>
    <repository>
        <id>maven2-repository.jboss.com</id>
        <url>http://repository.jboss.com/maven2</url>
    </repository>
    <repository>
        <id>maven2-apache</id>
        <url>http://ftp.cica.es/mirrors/maven2/</url>
    </repository>

</repositories>

为什么我收到这些错误?我该如何解决?

由于

1 个答案:

答案 0 :(得分:1)

在这种情况下,重要的是你缺少maven-compiler-plugin的版本:

<build>
 <plugins>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.1</version>
    <configuration>
      <source>1.6</source>
      <target>1.6</target>
    </configuration>
  </plugin>
</plugins>

为什么要定义这么多的存储库,特别是Maven-1存储库?如果您确实需要,只需使用Central定义其他存储库。

测试maven构建的最佳方法是在命令行上执行此操作,如果它完美地将其放入Eclipse中。