为什么这个简单的maven项目不会构建?

时间:2015-03-14 02:54:04

标签: java maven

我正在尝试按照此处的说明按照说明构建简单的RESTful Web服务:http://www.mkyong.com/webservices/jax-rs/jersey-hello-world-example/

但是,每当我尝试使用“mvn clean package”构建项目时,我总会收到以下错误:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building RESTfulExample Maven Webapp
[INFO]    task-segment: [clean, package]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory /home/username/RESTfulExample/target
[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] Failed to resolve artifact.

Unable to get dependency information: Unable to read the metadata file for artifact 'com.sun.jersey:jersey-server:jar': Cannot find parent: com.sun.jersey:jersey-project for project: null:jersey-server:bundle:null for project null:jersey-server:bundle:null
  com.sun.jersey:jersey-server:jar:1.8

from the specified remote repositories:
  central (http://repo1.maven.org/maven2),
  maven2-repository.java.net (http://download.java.net/maven/2/)

Path to dependency:
    1) com.mkyong.rest:RESTfulExample:war:1.0-SNAPSHOT



[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Fri Mar 13 22:48:22 EDT 2015
[INFO] Final Memory: 10M/212M
[INFO] ------------------------------------------------------------------------

我已多次完全删除了我的.m2目录,但这没有帮助。从另一篇StackOverflow文章中,我已从pom文件中删除了“存储库”部分,但这也无济于事。

这应该是一个简单的“Hello World”项目,但它让我发疯。

[编辑]添加了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.rest</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>3.8.1</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>
    </build>
</project>

0 个答案:

没有答案