Tomcat 7 maven build与Jersey失败了

时间:2014-08-29 03:48:33

标签: java maven tomcat jersey

我正在尝试用eclipe Luna中的Jersey 2.5设置maven项目。

这可能是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>MavenTest</groupId>
  <artifactId>Jersey Project</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>MC-Server Maven Webapp</name>

  <url>http://maven.apache.org</url>   

      <pluginRepositories>
        <pluginRepository>
        <id>apache.snapshots</id>
        <name>Apache Snapshots</name>
        <url>http://people.apache.org/repo/m2-snapshot-repository</url>
        <releases>
        <enabled>false</enabled>
        </releases>
        <snapshots>
        <enabled>true</enabled>
        </snapshots>
        </pluginRepository>
    </pluginRepositories>


    <build>
    <finalName>MavenJerseyTest</finalName>   

    <plugins>        
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.1</version>    
        </plugin>                     
    </plugins>    

  </build>

  <dependencies>
  <dependency>
 <groupId>org.glassfish.jersey.containers</groupId>
 <artifactId>jersey-container-servlet</artifactId>
 <version>2.5.1</version>
</dependency>
  </dependencies>

</project>    

当我构建它时

[INFO] Scanning for projects...
[WARNING] The POM for org.apache.tomcat.maven:tomcat7-maven-plugin:jar:7 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.apache.tomcat.maven:tomcat7-maven-plugin:7: Plugin org.apache.tomcat.maven:tomcat7-maven-plugin:7 or one of its dependencies could not be resolved: Failure to find org.apache.tomcat.maven:tomcat7-maven-plugin:jar:7 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
[INFO] Downloading: http://people.apache.org/repo/m2-snapshot-repository/org/apache/maven/plugins/maven-metadata.xml
[INFO] Downloading: http://people.apache.org/repo/m2-snapshot-repository/org/codehaus/mojo/maven-metadata.xml
[WARNING] Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from/to apache.snapshots (http://people.apache.org/repo/m2-snapshot-repository): connect timed out
[WARNING] Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/to apache.snapshots (http://people.apache.org/repo/m2-snapshot-repository): connect timed out
[INFO] Downloading: http://people.apache.org/repo/m2-snapshot-repository/org/codehaus/mojo/tomcat-maven-plugin/maven-metadata.xml
[WARNING] Could not transfer metadata org.codehaus.mojo:tomcat-maven-plugin/maven-metadata.xml from/to apache.snapshots (http://people.apache.org/repo/m2-snapshot-repository): connect timed out
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building MC-Server Maven Webapp 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for org.apache.tomcat.maven:tomcat7-maven-plugin:jar:7 is missing, no dependency information available
[WARNING] Failed to retrieve plugin descriptor for org.apache.tomcat.maven:tomcat7-maven-plugin:7: Plugin org.apache.tomcat.maven:tomcat7-maven-plugin:7 or one of its dependencies could not be resolved: Failure to find org.apache.tomcat.maven:tomcat7-maven-plugin:jar:7 in http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
[WARNING] Failure to transfer org.apache.maven.plugins/maven-metadata.xml from http://people.apache.org/repo/m2-snapshot-repository was cached in the local repository, resolution will not be reattempted until the update interval of apache.snapshots has elapsed or updates are forced. Original error: Could not transfer metadata org.apache.maven.plugins/maven-metadata.xml from/to apache.snapshots (http://people.apache.org/repo/m2-snapshot-repository): connect timed out
[WARNING] Failure to transfer org.codehaus.mojo/maven-metadata.xml from http://people.apache.org/repo/m2-snapshot-repository was cached in the local repository, resolution will not be reattempted until the update interval of apache.snapshots has elapsed or updates are forced. Original error: Could not transfer metadata org.codehaus.mojo/maven-metadata.xml from/to apache.snapshots (http://people.apache.org/repo/m2-snapshot-repository): connect timed out
[WARNING] Failure to transfer org.codehaus.mojo:tomcat-maven-plugin/maven-metadata.xml from http://people.apache.org/repo/m2-snapshot-repository was cached in the local repository, resolution will not be reattempted until the update interval of apache.snapshots has elapsed or updates are forced. Original error: Could not transfer metadata org.codehaus.mojo:tomcat-maven-plugin/maven-metadata.xml from/to apache.snapshots (http://people.apache.org/repo/m2-snapshot-repository): connect timed out
[INFO] 
[INFO] >>> tomcat-maven-plugin:1.1:run (default-cli) @ MC-Server >>>
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ MC-Server ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is plat
form dependent!
[INFO] Copying 3 resources
[INFO] 
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ MC-Server ---
[INFO] No sources to compile
[INFO] 
[INFO] <<< tomcat-maven-plugin:1.1:run (default-cli) @ MC-Server <<<
[INFO] 
[INFO] --- tomcat-maven-plugin:1.1:run (default-cli) @ MC-Server ---
[INFO] Running war on http://localhost:8080/MavenJerseyTest
[INFO] Creating Tomcat server configuration at /myprojects/maven/MavenJerseyTest/target/tomcat    

这似乎不适用于tomcat 7,但是6。

任何人让我知道我哪里出错了? (这个相同的项目结构可以在eclipse中构建为一个noraml web项目并且工作平静,也有同样的问题,如this,但我尝试了它们,不工作..我将tomcat插件版本更改为2.1,这是建议作为另一个问题的答案,它也没有用。)

1 个答案:

答案 0 :(得分:2)

这不可能是因为泽西岛。更改tomcat插件的pom.xml

<plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.2</version>
        </plugin>   

和tomcat目标:tomcat7:redeploy