eclipse - maven clean 不能在 sts 中使用 tomcat 1.8

标签 eclipse maven tomcat

我正在升级我的项目 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 构建的新手,请帮助我解决问题。

最佳答案

你的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 一起使用。

祝你好运!

关于eclipse - maven clean 不能在 sts 中使用 tomcat 1.8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36623009/

相关文章:

java - 有什么办法让 Eclipse 中的 "Open Declaration"移动到 Autowiring 服务吗?

eclipse - 如何避免 Eclipse 2020-03 中 GWT ui.xml 文件的错误消息(语言服务器)

java - 使用 maven 插件将静态资源上传到 Amazon s3 服务器

java - NoClassDefFoundError JIRA REST API

java - doGet 方法在 tomcat 7 中运行的 servlet 中被调用两次,并使用 IntelliJ Idea 12 创建

tomcat - Tomcat 6 上的 Grails 2.3.5 - 兼容性问题?

java - 无法访问 res 文件夹?

css - <link> 标签不导入 .css

maven - 如何抑制关于多个绑定(bind)的 SLF4J 警告?

jsp - 将 .jsp 作为 .html 文件运行