Tomcat 8 Maven Plugin for Java 8

前端 未结 6 1327
臣服心动
臣服心动 2020-11-28 04:58

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

相关标签:
6条回答
  • 2020-11-28 05:29

    An other solution (if possible) would be to use TomEE instead of Tomcat, which has a working maven plugin:

    <plugin>
        <groupId>org.apache.tomee.maven</groupId>
        <artifactId>tomee-maven-plugin</artifactId>
        <version>7.1.1</version>
    </plugin>
    

    Version 7.1.1 wraps a Tomcat 8.5.41

    0 讨论(0)
  • 2020-11-28 05:32

    Since November 2017, one can use tomcat8-maven-plugin:

    <!-- https://mvnrepository.com/artifact/org.apache.tomcat.maven/tomcat8-maven-plugin -->
    <dependency>
        <groupId>org.apache.tomcat.maven</groupId>
        <artifactId>tomcat8-maven-plugin</artifactId>
        <version>2.2</version>
    </dependency>
    

    Note that this plugin resides in ICM repo (not in Maven Central), hence you should add the repo to your pluginsRepositories in your pom.xml:

    <pluginRepositories>
        <pluginRepository>
            <id>icm</id>
            <name>Spring Framework Milestone Repository</name>
            <url>http://maven.icm.edu.pl/artifactory/repo</url>
        </pluginRepository>
    </pluginRepositories>
    
    0 讨论(0)
  • 2020-11-28 05:32

    groupId and Mojo name change Since version 2.0-beta-1 tomcat mojos has been renamed to tomcat6 and tomcat7 with the same goals.

    You must configure your pom to use this new groupId:

    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.apache.tomcat.maven</groupId>
          <artifactId>tomcat6-maven-plugin</artifactId>
          <version>2.3-SNAPSHOT</version>
        </plugin>
        <plugin>
          <groupId>org.apache.tomcat.maven</groupId>
          <artifactId>tomcat7-maven-plugin</artifactId>
          <version>2.3-SNAPSHOT</version>
        </plugin>
      </plugins>
    </pluginManagement>
    

    Or add the groupId in your settings.xml

    .... org.apache.tomcat.maven ....

    0 讨论(0)
  • 2020-11-28 05:33

    Plugin run Tomcat 7.0.47:

    mvn org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:run

     ...
     INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
    

    This is sample to run plugin with Tomcat 8 and Java 8: Cargo embedded tomcat: custom context.xml

    0 讨论(0)
  • 2020-11-28 05:36

    Almost 2 years later....
    This github project readme has a some clarity of configuration of the maven plugin and it seems, according to this apache github project, the plugin itself will materialise soon enough.

    0 讨论(0)
  • 2020-11-28 05:37

    Yes you can,

    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)

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

    * deploy/re-deploy

    mvn tomcat7:deploy OR mvn tomcat7:redeploy

    Tried this on (Both Ubuntu and Windows 8/10):
    * Jdk 7 & Tomcat 7
    * Jdk 7 & Tomcat 8
    * Jdk 8 & Tomcat 7
    * Jdk 8 & Tomcat 8
    * Jdk 8 & Tomcat 9

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

    Note:
    Tomcat manager should be running or properly setup, before you can use it with maven.

    Good Luck!

    0 讨论(0)
提交回复
热议问题