问题描述
有没有办法在不更改pom.xml
或应用程序源的情况下将单个Spring Boot项目打包到JAR和WAR中?
Is there a way to have a single Spring Boot project be packagable into both JAR and WAR without changing the pom.xml
or the application source?
我已阅读将Spring Boot JAR应用程序转换为WAR a>,但是它将转换为WAR,并且无法打包为JAR.
I've read Converting a Spring Boot JAR Application to a WAR, but it converts the project to WAR and it loses the ability to be packaged as JAR.
我不希望mvn package
同时执行.我想要的是类似mvn i-want-a-jar
的东西,它将项目打包为JAR.或者,我可以运行mvn i-want-a-war
,它将项目打包为WAR.
I don't expect mvn package
to do both. What I want is something like mvn i-want-a-jar
and it would package the project as JAR. Or I could run mvn i-want-a-war
and it would package the project as WAR.
这可能吗?
推荐答案
可执行的WAR文件怎么了?那不是您真正需要的吗?
What's wrong with a WAR file that's executable? Isn't that what you really need?
P.S.喜欢java -jar name.war
P.S. likejava -jar name.war
这篇关于一个Spring Boot项目,同时部署到JAR或WAR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!