maven clean在tomcat 1.8中没有工作

时间:2016-04-14 12:23:36

标签: eclipse maven tomcat

我正在升级我的项目 1)Tomcat 1.7到tomcat 1.8 2)STS 2. *到STS3。* 3)maven 2. *到Maven 3。*

在STS升级后,当我做maven清理时,我得到以下错误

[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building Bna4AllService 0.0.1
[INFO] ------------------------------------------------------------------------
[INFO] Downloading: https://repo.maven.apache.org/maven2/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 central (https://repo.maven.apache.org/maven2): This is usually a temporary error during hostname resolution and means that the local server did not receive a response from an authoritative server
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.776 s
[INFO] Finished at: 2016-04-14T17:46:34+05:30
[INFO] Final Memory: 8M/121M
[INFO] ------------------------------------------------------------------------
[ERROR] Error resolving version for plugin 'org.codehaus.mojo:tomcat-maven-plugin' from the repositories [local (C:\Users\nreddy\.m2\repository), central (https://repo.maven.apache.org/maven2)]: Plugin not found in any plugin repository -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginVersionResolutionException

我的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.eeft</groupId>
    <artifactId>bna4AllService</artifactId>
    <version>0.0.1</version>
    <packaging>war</packaging>
    <name>Bna4AllService</name>
    <dependencies>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>2.7.3</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>2.7.3</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring</artifactId>
            <version>2.5.6.SEC03</version>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.3</version>
        </dependency>
        <dependency>
            <groupId>com.eeft</groupId>
            <artifactId>bna4AllServiceImplementation</artifactId>
            <version>0.0.1</version>
        </dependency>

        <dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.14</version>
</dependency>
    </dependencies>

    <build>
        <finalName>${project.artifactId}</finalName>
        <pluginManagement>
            <plugins>
                <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.3</version>
                   <configuration>
                      <archive>
                         <manifest>
                         </manifest>
                         <manifestEntries>
                            <DisableIBMJAXWSEngine>true</DisableIBMJAXWSEngine>
                         </manifestEntries>
                      </archive>
                   </configuration>
                </plugin>
                <plugin> 
                   <groupId>org.codehaus.mojo</groupId> 
                   <artifactId>tomcat-maven-plugin</artifactId> 
                   <configuration> 
                      <server>myserver</server>
                      <url>http://localhost:8080/manager/html</url> 
                   </configuration> 
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.7</source>
                        <target>1.7</target>
                        <skipTests>true</skipTests>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.13</version>
                  </plugin>
            </plugins>
        </pluginManagement>
    </build>

</project>

我对mvaen版本很新,请帮我解决问题。

1 个答案:

答案 0 :(得分:1)

您配置tomcat是错误的。 在你的pom.xml中,添加tomcat插件。 (您可以将它用于Tomcat 7和8):

<强>的pom.xml

<!-- Tomcat plugin -->  
<plugin>  
 <groupId>org.apache.tomcat.maven</groupId>  
 <artifactId>tomcat7-maven-plugin</artifactId>  
 <version>2.2</version>  
 <configuration>  
  <url>http:// localhost:8080/manager/text</url>  
  <server>TomcatServer</server>    *(From maven > settings.xml)*
  <username>*yourtomcatusername*</username>  
  <password>*yourtomcatpassword*</password>   
 </configuration>   
</plugin>   

<强> Tomcat的users.xml中

<tomcat-users>
    <role rolename="manager-gui"/>  
        <role rolename="manager-script"/>   
        <user username="admin" password="password" roles="manager-gui,manager-script" />  
</tomcat-users>

settings.xml (maven&gt; conf)

<servers>  
    <server>
       <id>TomcatServer</id>
       <username>admin</username>
       <password>password</password>
    </server>
</servers>  

*部署/重新部署

mvn tomcat7:deploy OR mvn tomcat7:redeploy

尝试了这个(Ubuntu和Windows 8/10):  * Jdk 7&amp;雄猫7  * Jdk 8&amp;雄猫7  * Jdk 8&amp; Tomcat 8

还没有尝试过Jdk 7&amp; Tomcat 8虽然:)

注意: Tomcat管理器应该运行或正确设置,然后才能与maven一起使用。

祝你好运!