本文主要是介绍spring boot 打war 包 外置tomcat,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
War 包 配置
一、Application.java 修改:
1.public class Application extends SpringBootServletInitializer
2. 增加一个方法(可以先不加,有问题再加上也行):
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(this.getClass());
}
二、pom.xml 修改:
1. <packaging>war</packaging>
2.<!-- 打war包时加入此项, 告诉spring-boot tomcat相关jar包用外部的,不要打进去 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
四、添加第三方依赖包:
1、在pom.xml 添加代码配置
<dependency>
<groupId>accenture.code.smartrecon.logical</groupId>
<artifactId>logical</artifactId>
<version>1.1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/logical_1.0.jar</systemPath>
</dependency>
<dependency>
<groupId>org.dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/dom4j-1.6.1.jar</systemPath>
</dependency>
2、Pom.xml包路径配置
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>lib</directory>
<targetPath>WEB-INF/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>
3、Pom.xml包路径配置
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.tld</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>lib</directory>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
这篇关于spring boot 打war 包 外置tomcat的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!