除了tomcat7-maven-plugin之外,我没有找到任何tomcat-maven-plugin。我可以将其与apache- tomcat-9.0.0.M15一起使用吗?
是的,您可以使用它。我尝试过,它对tomcat 9有效
<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目标:
mvn tomcat7:deploy mvn tomcat7:undeploy mvn tomcat7:redeploy
注意:不要忘记在tomcat-users.xml和maven settings.xml中添加tomcat用户。
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 角色使应用程序(例如maven)能够将jar / war部署到应用程序服务器。
Maven文件settings.xml
<?xml version="1.0" encoding="UTF-8"?> <settings ...> <servers> <server> <id>TomcatServer</id> <username>admin</username> <password>password</password> </server> </servers> </settings>