Tomcat 9 的 Maven 插件
Maven plugin for Tomcat 9
除了 tomcat7-maven-plugin,我没有找到任何 tomcat-maven-plugin。
我可以将它与 apache-tomcat-9.0.0.M15 一起使用吗?
您可以使用插件单独部署到运行 tomcat 9.
run
个目标不起作用,但 deploy
个目标会起作用。
<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>
如其他答案所述,tomcat7-maven-plugin 仍可用于部署到 运行ning Tomcat 9 并带有管理器应用程序.不过要运行 embedded Tomcat 9、试试Cargo插件:
<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>
开始于:
mvn org.codehaus.cargo:cargo-maven2-plugin:run
我很长时间都在寻找同一个问题的答案。现在我找到了。
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.8.3</version>
<configuration>
<container>
<containerId>tomcat9x</containerId>
<type>embedded</type>
</container>
<deployables>
<deployable>
<type>war</type>
<location>${project.build.directory}/${project.build.finalName}.war</location>
<properties>
<context>/</context>
</properties>
</deployable>
</deployables>
</configuration>
</plugin>
和运行与
mvn package cargo:run
除了 tomcat7-maven-plugin,我没有找到任何 tomcat-maven-plugin。 我可以将它与 apache-tomcat-9.0.0.M15 一起使用吗?
您可以使用插件单独部署到运行 tomcat 9.
run
个目标不起作用,但 deploy
个目标会起作用。
<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>
如其他答案所述,tomcat7-maven-plugin 仍可用于部署到 运行ning Tomcat 9 并带有管理器应用程序.不过要运行 embedded Tomcat 9、试试Cargo插件:
<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>
开始于:
mvn org.codehaus.cargo:cargo-maven2-plugin:run
我很长时间都在寻找同一个问题的答案。现在我找到了。
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.8.3</version>
<configuration>
<container>
<containerId>tomcat9x</containerId>
<type>embedded</type>
</container>
<deployables>
<deployable>
<type>war</type>
<location>${project.build.directory}/${project.build.finalName}.war</location>
<properties>
<context>/</context>
</properties>
</deployable>
</deployables>
</configuration>
</plugin>
和运行与
mvn package cargo:run