将Maven工程导出war包(导出可执行文件)

本文介绍如何通过修改pom.xml文件配置Tomcat服务器,实现WAR包的自动化部署过程。主要内容包括设置必要的插件配置、指定JVM参数、生成启动脚本等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1  打开war工程的pom.xml,将如下内容复制到配置Tomcat的代码中

                <plugin>
	             <groupId>org.codehaus.mojo</groupId>
	             <artifactId>appassembler-maven-plugin</artifactId>
	             <version>1.1.1</version>
	             <configuration>
	                 <repositoryLayout>flat</repositoryLayout>
	                 <repositoryName>lib</repositoryName>
	                 <configurationSourceDirectory>src/main/resources/conf</configurationSourceDirectory>
	                 <!-- Set the target configuration directory to be used in the bin scripts -->
	                 <configurationDirectory>conf</configurationDirectory>
	                 <!-- Copy the contents from "/src/main/config" to the target configuration
	                     directory in the assembled application -->
	                 <copyConfigurationDirectory>true</copyConfigurationDirectory>
	                 <!-- Include the target configuration directory in the beginning of
	                     the classpath declaration in the bin scripts -->
	                 <includeConfigurationDirectoryInClasspath>true</includeConfigurationDirectoryInClasspath>
	                 <!-- prefix all bin files with "mycompany" -->
	                 <binPrefix>startup</binPrefix>
	                 <!-- set alternative assemble directory -->
	                 <assembleDirectory>${project.build.directory}/server</assembleDirectory>
	                 <!-- Extra JVM arguments that will be included in the bin scripts -->
	                 <extraJvmArguments>-Xms768m -Xmx768m -XX:PermSize=128m
	                     -XX:MaxPermSize=256m -XX:NewSize=192m -XX:MaxNewSize=384m
	                 </extraJvmArguments>
	                 <!-- Generate bin scripts for windows and unix pr default -->
	                 <platforms>
	                     <platform>windows</platform>
	                     <platform>unix</platform>
	                 </platforms>
	                 <programs>
	                     <program>
	                         <mainClass>com.coderli.onecoder.server.HypervisorServer</mainClass>
	                         <name>startup</name>
	                     </program>
	                 </programs>
	             </configuration>
	         </plugin>

2  右击该项目--> Run As --> Maven install

3  运行完成后会在targer中存放




war包的安装与部署(以两个Tomcat为例,详细)请到:

   https://blog.youkuaiyun.com/Love_codes/article/details/80837625

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值