Maven plugin for Tomcat 9
As stated in other answer, tomcat7-maven-plugin can still be used to deploy into a running Tomcat 9 with manager app present. However, to run embedded Tomcat 9, try the Cargo plugin:
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.7.6</version>
<configuration>
<container>
<containerId>tomcat9x</containerId>
<type>embedded</type>
</container>
</configuration>
</plugin>
Start it with:
mvn org.codehaus.cargo:cargo-maven2-plugin:run
You can use the plugin to deploy to a separately running tomcat 9.
The run
goals won't work, but the deploy
goals will.
<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>
<path>/myapp</path>
</configuration>
</plugin>
Maven goals:
mvn tomcat7:deploy
mvn tomcat7:undeploy
mvn tomcat7:redeploy
Note: Don't forget to add tomcat user in tomcat-users.xml and maven settings.xml
tomcat-user.xml
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="admin" password="password" roles="manager-gui,manager-script" />
</tomcat-users>
manager-script role enables applications i.e., maven, to deploy jar/war to application server.
Maven file settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings ...>
<servers>
<server>
<id>TomcatServer</id>
<username>admin</username>
<password>password</password>
</server>
</servers>
</settings>