除了tomcat7-maven-plugin之外,我没有找到任何tomcat-maven-plugin。我可以在apache-tomcat-9.0.0.M15中使用它吗?
发布于 2017-10-12 21:27:33
您可以使用该插件将其部署到单独运行的tomcat9。
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>发布于 2019-08-06 21:08:03
正如在其他答案中所述,tomcat7-maven-plugin仍然可以用于部署到运行中的Tomcat9中,并提供管理器应用程序。但是,要运行embedded Tomcat9,请尝试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发布于 2020-12-26 20:07:25
我在很长一段时间里都在寻找相同问题的答案。现在我发现了。
<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:runhttps://stackoverflow.com/questions/41326911
复制相似问题