让 Eclipse Juno、maven 2.2.1 和 m2eclipse 在 Red Hat Linux 平台上运行...
下载了一个简单的示例来构建一个Restful Hello World Web服务(适用于我的OS X计算机),但由于某种奇怪的原因,它不适用于我的Linux机器。
这是pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mkyong.common</groupId>
<artifactId>RESTfulExample</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>RESTfulExample Maven Webapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>maven2-repository.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.8</version>
</dependency>
</dependencies>
<build>
<finalName>RESTfulExample</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
当我尝试从命令行发出 mvn 编译时:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building RESTfulExample Maven Webapp
[INFO] task-segment: [compile]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: null:jersey-server:bundle:null
Reason: Cannot find parent: com.sun.jersey:jersey-project for project: null:jersey -server:bundle:null for project null:jersey-server:bundle:null
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Thu Nov 15 17:07:16 PST 2012
[INFO] Final Memory: 8M/309M
[INFO] ------------------------------------------------------------------------
有人遇到过这个问题吗?我不明白它在我的OS X计算机上是如何工作的,但在Linux上却不明白(我认为这不是问题)。
感谢您抽出宝贵时间阅读本文。
我会完全删除您的pom.xml文件中的整个repositories
元素。 这样 maven 将使用标准的中央存储库。然后将 jersey 服务器的版本更改为 1.15(最新)。
该 java.net 存储库中的最新球衣日期为 2011 年 8 月,而标准中央 maven 存储库的版本为 1.15,日期为 2012 年 10 月 30 日。
我怀疑它在一台机器上而不是另一台机器上运行的原因是,在您的 ~/.m2/repository 缓存中,您在一台机器上有很好的缓存文件,但在另一台机器上没有。 可能需要删除整个 ~/.m2/repository/com/sun/jersey 层次结构并重建。 您可能那里的文件已损坏。