java - Tomcat 7 Maven 构建因 Jersey 而失败

标签 java maven tomcat jersey

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

这里是may 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,建议为另一个问题的答案,它也没有用..)

最佳答案

这不可能是因为 Jersey 。修改tomcat插件的pom.xml

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

对于 tomcat 目标:tomcat7:redeploy

关于java - Tomcat 7 Maven 构建因 Jersey 而失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25561421/

相关文章:

java - 迭代 HashMap 的数字和字母

Java继承层次动物类

java - 字节数组到数字的高效解析

java - 为 Spark 创建 JAR

java - Datanucleus JDO 中的映射属性

java - 在 Intellij 中添加 Maven 依赖

IntelliJ IDEA 中的 Tomcat 配置

java - Apache Storm 应用程序运行失败

java - 增加永久空间

tomcat - 在 EC2 Tomcat 服务器上安装 SSL