1、SpringBoot 项目jar启动
java -jar chcservice.jar
2、SpringBoot 项目部署至本地tomcat
改成war
<groupId>com.lming</groupId> <artifactId>chcservice</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>war</packaging>
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- war包部署 移除springboot内置容器--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> <scope>provided</scope> </dependency>
<!-- 采用容器启动 3.1.0 --> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> </dependency>
<!-- maven编译war插件 -->
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <warSourceExcludes>src/main/resources/**</warSourceExcludes> <warName>chcservice</warName> </configuration> </plugin>
2、与项目同级启动类添加一个类
/** * @Author shinyZo * @date 2017-11-27 * @description */ public class ChcServiceStartup extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(ChcserviceApplication.class); } }
3、mvn编译
mvn clean package -Dmaven.test.skip=true
编译完成war包在target目录下
4、将war包放在tomcat7 的webapps目录下 ,启动startup.bat 项目会自行解压;