mck*_*mey 19 java deployment tomcat maven tomcat7
我一直在mvn tomcat7-maven-plugin:run -am -pl :foo成功使用Tomcat中的一个项目,如此处所示.现在我想让多个模块在相同的端口下运行但不同的上下文.例如,我想:
/ => foo.war
/bar => bar.war
Run Code Online (Sandbox Code Playgroud)
这是我一直在使用的示例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>
Run Code Online (Sandbox Code Playgroud)
这个tomcat7-maven-plugin:run插件可以实现吗?我很难找到正确的语法来让它发挥得很好.当我运行maven命令来运行它时,它只运行它在项目层次结构中找到的第一个命令.如果我使用<fork>true</fork>或显然从不同的终端运行它们然后我得到"java.net.BindException:地址已在使用:8080".
Vas*_*kin 20
正如已经建议的那样,使用<webapps>插件配置部分,但<asWebapp>true</asWebapp>为每个webapp 添加额外的参数,即:
<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>
Run Code Online (Sandbox Code Playgroud)
${artifactId}默认情况下,这些其他Web应用程序使用上下文路径进行部署
看起来如果没有这个参数,当你运行类似的东西mvn tomcat7:run(在稳定版本2.0上试过)时,会无声地丢弃额外的webapps .相关的Jira问题告诉它是为了"向后兼容性"而完成的.
使用类似的东西
<configuration>
<webapps>
<webapp>
<groupId>com.company</groupId>
<artifactId>mywebapp</artifactId>
<version>1.0</version>
<type>war</type>
</webapp>
</webapps>
</configuration>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18113 次 |
| 最近记录: |