0

我是 Maven 和 Eclipse 配置的新手。我在 Eclipse 中设置了我的 Maven 路径

在此处输入图像描述

然后我在eclipse中做了一个项目运行配置

在此处输入图像描述

这是我的 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>

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

谢谢

4

1 回答 1

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 中。

于 2013-05-06T16:42:09.050 回答