云上服务器发布rocket api步骤
1、在RocketAPIApplication同级目录下创建SpringStartApplication
package com.github.alenfive.rocketapi;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
//@SpringBootApplication
public class SpringStartApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(RocketAPIApplication.class);
}
}
2、在pom中设置打包为war包
<packaging>war</packaging>
3、注释掉不必要的打包插件,留下如下打包插件
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<addResources>true</addResources>
<mainClass>com.github.alenfive.rocketapi.RocketAPIApplication</mainClass>
<classifier>exec</classifier>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
<finalName>interfaceUI</finalName>
4、pom中注释掉provided,除了spring-boot-starter-tomcat
当我们用maven install生成最终的构件包ProjectABC.war后,在其下的WEB-INF/lib中,会包含我们被标注为scope=compile的构件的jar包,而不会包含我们被标注为scope=provided的构件的jar包。这也避免了此类构件当部署到目标容器后产生包依赖冲突。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
5、打包到tomcat的webapps下
6、运行tomcat的startup.bat,编译,访问http://localhost:8080/war包名/interface-ui
如war包名为interfaceUI.war,则访问地址为
http://localhost:8080/interfaceUI/interface-ui