springboot文件打包成jar或war的方法
jar:
pom.xml:
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
其他不变
maven -> package
找到 jar 包,cmd -> java -jar xx.jar
war:
pom.xml:
<packaging>war</packaging>
启动类 继承 SpringBootServletInitializer,重写 configure
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
}
其他不变
maven -> package
找到 war 包,丢到 tomcat,启动、访问
以上是 springboot文件打包成jar或war的方法 的全部内容, 来源链接: utcz.com/z/312443.html