SpringBoot生成war,部署到tomcat
2019-12-23 本文已影响0人
我想专心学习
第一步:设置packaging为war
<groupId>com.lfq</groupId>
<artifactId>tomcat-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>tomcat-test</name>
<description>Demo project for Spring Boot</description>
<packaging>war</packaging>
第二步:修改web依赖、servlet依赖、jsp依赖(jsp页面用的上)
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
</dependency>
可以自定义最后的war包名称:
![](https://img.haomeiwen.com/i16284529/496ab67d3453a62d.png)
![](https://img.haomeiwen.com/i16284529/d301a2822a487d94.png)
等待Build Success
![](https://img.haomeiwen.com/i16284529/d99326668c71bd23.png)
![](https://img.haomeiwen.com/i16284529/0a724869f5143ea7.png)
图上的三个文件直接粘贴到webapp目录下
![](https://img.haomeiwen.com/i16284529/b45cf08a518fd869.png)
最后启动tomcat的bin目录下的startup.bat,war包的服务就可以正常跑起来了。
![](https://img.haomeiwen.com/i16284529/c2fb2f8e3c497b5c.png)