Reputation: 4435
Is the tomcat7-maven-plugin
working with a tomcat 8 server and java 8? I can't find any tomcat8-maven-plugin
.
Upvotes: 81
Views: 126932
Reputation: 2038
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):
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!
Upvotes: 81
Reputation: 2073
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
Upvotes: 0
Reputation: 8839
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>
Upvotes: 0
Reputation: 27
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 ....
Upvotes: -1
Reputation: 7393
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.
Upvotes: 1
Reputation: 18000
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
Upvotes: 6