【问题标题】:maven clean not working in sts with tomcat 1.8maven clean 无法在 sts 中使用 tomcat 1.8
【发布时间】:2023-03-06 16:19:01
【问题描述】:

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

当我在 STS 中进行 maven clean 升级后,我遇到了错误

[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 构建的新手,请帮我解决问题。

【问题讨论】:

    标签: eclipse maven tomcat


    【解决方案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 > conf)

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

    * 部署/重新部署

    mvn tomcat7:deploy 或 mvn tomcat7:redeploy

    在(Ubuntu 和 Windows 8/10)上试过这个: * Jdk 7 & Tomcat 7 * JDK 8 & Tomcat 7 * Jdk 8 & Tomcat 8

    虽然没有在 Jdk 7 和 Tomcat 8 上尝试过 :)

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

    祝你好运!

    【讨论】:

    • 谢谢!霍恩海姆……让我试试这个。
    • 这个教程一点都不差link
    猜你喜欢
    • 2012-02-24
    • 2012-01-19
    • 1970-01-01
    • 1970-01-01
    • 2015-03-14
    • 2011-06-25
    • 2018-05-18
    • 2011-01-15
    • 2011-04-19
    相关资源
    最近更新 更多