我已经成功地使用mvn tomcat7-maven-plugin:run -am -pl :foo
在Tomcat like is shown here中一次只运行一个项目。现在,我想让多个模块在相同的端口下运行,但在不同的上下文中运行。例如,我想要:
/ => foo.war
/bar => bar.war
下面是我一直在使用的示例pom.xml代码片段:
<project><!-- ... -->
<build><!-- ... -->
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.0-SNAPSHOT</version>
<configuration>
<path>/</path>
<port>8080</port>
<addContextWarDependencies>true</addContextWarDependencies>
<addWarDependenciesInClassloader>true</addWarDependenciesInClassloader>
<warSourceDirectory>${project.build.directory}/${project.build.finalName}/</warSourceDirectory>
</configuration>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>bar</artifactId>
<version>${project.version}</version>
<type>war</type>
<scope>tomcat</scope>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
<pluginRepositories>
<pluginRepository>
<id>apache.snapshots</id>
<name>Apache Snapshots</name>
<url>http://repository.apache.org/content/groups/snapshots-group/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
tomcat7-maven-plugin:run
插件可以做到这一点吗?我正在努力寻找正确的语法来让它很好地播放。当我运行maven
命令来运行它时,它只运行它在项目层次结构中找到的第一个项目。如果我用<fork>true</fork>
运行它们,或者显然是从不同的终端运行它们,那么我会得到"java.net.BindException: Address already in use :8080“。
发布于 2012-11-02 19:02:46
正如已经建议的,使用插件配置的<webapps>
部分,但为每个webapp添加额外的参数<asWebapp>true</asWebapp>
,即:
<webapps>
<webapp>
<groupId>com.company</groupId>
<artifactId>mywebapp</artifactId>
<version>1.0</version>
<type>war</type>
<asWebapp>true</asWebapp>
</webapp>
<webapp>
<groupId>com.company</groupId>
<artifactId>mywebapp2</artifactId>
<version>2.0</version>
<type>war</type>
<asWebapp>true</asWebapp>
</webapp>
</webapps>
默认情况下,这些额外的are应用程序使用${artifactId}
上下文路径进行部署。
看起来,如果没有这个参数,当你运行像mvn tomcat7:run
这样的东西(在稳定版本2.0上试用)时,额外的when应用程序就会被悄悄丢弃。Related Jira issue说这样做是为了“向后兼容”。
发布于 2012-08-16 05:20:12
使用像这样的东西
<configuration>
<webapps>
<webapp>
<groupId>com.company</groupId>
<artifactId>mywebapp</artifactId>
<version>1.0</version>
<type>war</type>
</webapp>
</webapps>
</configuration>
https://stackoverflow.com/questions/11959975
复制相似问题