使用Maven pom.xml将战争文件部署到Tomcat根目录 [英] Deploying a War File to Tomcat Root With Maven pom.xml
本文介绍了使用Maven pom.xml将战争文件部署到Tomcat根目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
pom.xml
maven将构建一个 client.war
文件,当Tomcat部署到网址 www.server.com:8080/client /
需要更改哪些应用程序才能在服务器根目录下可达到 www.server.com:8080 /
?
<项目>
< modelVersion> 4.0.0< / modelVersion>
< groupId> ...< / groupId>
< artifactId>客户端< / artifactId>
< packaging> war< / packaging>
< version> 1.0-SNAPSHOT< / version>
< name> ...< / name>
< url> http://maven.apache.org< / url>
< build>
< resources>
< resource>
< directory> target / generated-resources< / directory>
< / resource>
< resource>
< directory> src / main / resources< / directory>
< filtering> true< / filtering>
< / resource>
< / resources>
< plugins>
...
< / plugins>
< finalName> client< / finalName>
< / build>
...
< / project>
解决方案
我相信你如果你愿意,可以离开名为client.war的战争。然后配置 tomcat6插件,设置路径如下:
< plugin>
< groupId> org.apache.tomcat.maven< / groupId>
< artifactId> tomcat6-maven-plugin< / artifactId>
< version> 2.0-beta-1< / version>
<! - 将配置放在执行中,如果你想... - >
< configuration>
< path> /< / path>
< warFile> $ {project.build.directory} /client.war</warFile>
<! - 其他配置选项 - >
< / configuration>
< / plugin>
我没有使用tomcat7版本的插件,但我猜这是类似的。 p>
Assuming the following pom.xml
maven would build a client.war
file which when deployed to Tomcat will have the URL www.server.com:8080/client/
What would one have to change so the application can be reached at the server root www.server.com:8080/
?
<project> <modelVersion>4.0.0</modelVersion> <groupId>...</groupId> <artifactId>client</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>...</name> <url>http://maven.apache.org</url> <build> <resources> <resource> <directory>target/generated-resources</directory> </resource> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> <plugins> ... </plugins> <finalName>client</finalName> </build> ... </project>
解决方案
I believe you can leave the war named client.war if you'd like. Then configure the tomcat6 plugin, setting the path like this:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.0-beta-1</version>
<!-- put the configuration in an execution if you want to... -->
<configuration>
<path>/</path>
<warFile>${project.build.directory}/client.war</warFile>
<!-- other config options here -->
</configuration>
</plugin>
I haven't used tomcat7 version of the plugin, but I'm guessing it's similar.
这篇关于使用Maven pom.xml将战争文件部署到Tomcat根目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文