SpringBoot如何进行项目打包部署

2020-04-22 科技 124阅读
1. springboot的打包方式有很多种。有打成war的,有打成jar的,也有直接提交到github
首先需要在application.properties当中配置端口
server.port=8080
2. marven的配置文件

http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0</modelVersion>
com.weixin</groupId>
smallsystem</artifactId>
0.0.1-SNAPSHOT</version>
jar</packaging>
smallsystem</name>
smallsystem</description>

org.springframework.boot</groupId>
spring-boot-starter-parent</artifactId>
2.0.0.RELEASE</version>

</parent>

UTF-8</project.build.sourceEncoding>
UTF-8</project.reporting.outputEncoding>
1.8</java.version>
</properties>


org.springframework.boot</groupId>
spring-boot-starter-web</artifactId>
</dependency>

org.springframework.boot</groupId>
spring-boot-starter-test</artifactId>
test</scope>
</dependency>

io.springfox</groupId>
springfox-swagger2</artifactId>
2.2.2</version>
</dependency>

io.springfox</groupId>
springfox-swagger-ui</artifactId>
2.2.2</version>
</dependency>

org.springframework.boot</groupId>
spring-boot-devtools</artifactId>
true</optional>
</dependency>
</dependencies>



org.springframework.boot</groupId>
spring-boot-maven-plugin</artifactId>

com.weixin.SmallsystemApplication</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project>
在启动类当中加上extends SpringBootServletInitializer并重写configure方法,这是为了打包springboot项目用的。
@SpringBootApplication
public class SmallsystemApplication extends SpringBootServletInitializer{
public static void main(String[] args) {
SpringApplication.run(SmallsystemApplication.class, args);
}
@Override//为了打包springboot项目
protected SpringApplicationBuilder configure(
SpringApplicationBuilder builder) {
return builder.sources(this.getClass());
}
}
然后按照顺序运行mvn clean再mvn install
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com