springboot 打包成 jar 或 war
程序员文章站
2022-03-25 22:01:50
jar: pom.xml: 其他不变 maven -> package 找到 jar 包,cmd -> java -jar xx.jar war: pom.xml: 启动类 继承 SpringBootServletInitializer,重写 configure 其他不变 maven -> pack ......
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,启动、访问
推荐阅读