1.将pom.xml中的打包方式修改为war
com.borya Project 0.0.1-SNAPSHOT war
2.在pom.xml中添加依赖,将scope状态修改为provided
org.springframework.boot spring-boot-starter-tomcat provided
3.修改src/main/java下的application启动项
package com.borya;@SpringBootApplicationpublic class ProjectApplication extends SpringBootServletInitializer implements WebApplicationInitializer{ @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application){ return application.sources(ProjectApplication.class); } public static void main(String[] args) { SpringApplication.run(ProjectApplication.class, args); }}
4.重新build项目
5.菜单 Build -->> build artifacts -->> all artifacts -->> Build
6.此时项目已经成功打包成war包,位置在项目结构的target下,以.war结尾的就是项目
7.下面就是将项目发布到远程服务器上了,我这里使用的是WinSCP工具,登录成功后,直接将war包放到服务器tomcat下的webapps中,修改tomcat/conf中的server.xml
8.找到Host标签,在其中添加如下配置
9.重启tomcat
重启可以理解为先关闭tomcat+再启动tomcat
sh shutdown.shsh startup.sh