适用于 Java 8 的 Tomcat 8 Maven 插件

适用于 Java 8 的 Tomcat 8 Maven 插件

问题描述:

tomcat7-maven-plugin 是否与 tomcat 8 服务器和 java 8 一起使用?我找不到任何 tomcat8-maven-plugin.

Is the tomcat7-maven-plugin working with a tomcat 8 server and java 8? I can't find any tomcat8-maven-plugin.

是的,你可以,

在您的 pom.xml 中,添加 tomcat 插件.(您可以将它用于 Tomcat 7 和 8):

In your pom.xml, add the tomcat plugin. (You can use this for both Tomcat 7 and 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)

settings.xml (maven > conf)

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

*** 部署/重新部署**

*** deploy/re-deploy**

mvn tomcat7:deploymvn tomcat7:redeploy

在(Ubuntu 和 Windows 8/10)上尝试过:

  • Jdk 7 &雄猫 7
  • Jdk 7 &雄猫8
  • Jdk 8 &雄猫 7
  • Jdk 8 &雄猫8
  • Jdk 8 &雄猫9

在 Jdk 7/8 & 上测试雄猫 7/8.(适用于 Tomcat 8.5 和 9)

Tested on Both Jdk 7/8 & Tomcat 7/8. (Works with Tomcat 8.5 and 9)

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

祝你好运!