jar: pom.xml: packagingjar/packaging build plugins plugin groupIdorg.springframework.boot/groupId artifactIdspring-boot-maven-plugin/artifactId /plugin /plugins/build 其他不变 maven - package 找到 jar 包,cmd - java -jar xx.jar
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,启动、访问
以上就是本次整理的全部知识点内容,感谢大家对自由互联的支持。