[英]How to make SpringBoot project run through war package, and can also run through jar
I want my project to be launched on my personal computer via the Main function (either via java -jar
or by mvn spring-boot: run
), and when the development is complete, I can deploy it directly to Tomcat. 我希望通过Main函数(通过
java -jar
或mvn spring-boot: run
)在个人计算机上mvn spring-boot: run
,并且在开发完成后,可以将其直接部署到Tomcat。 How to configure, to do this 如何进行配置
You don't have to do anything special. 您不必做任何特别的事情。 Just follow the official documentation to build a deployable war.
只需按照官方文档进行部署即可。 The war file created using the Spring Boot build process is executable as a regular jar file as it contains an embedded servlet container in a separate directory called
lib-provided
which is added to the classpath only when the war is directly executed. 使用Spring Boot构建过程创建的war文件可以作为常规jar文件执行,因为它在名为
lib-provided
的单独目录中包含嵌入式servlet容器,仅在直接执行war时,该目录才会添加到类路径中。
Bonus: If you want to get rid of unnecessary dependencies on embedded server when creating a deployable war, you can check out a blog post , which show how to do it step-by-step. 奖励:如果您希望在创建可部署的战争时摆脱对嵌入式服务器的不必要依赖,则可以查看博客文章 ,该文章显示了如何逐步进行操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.