Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot War

I tend to use the runnable JAR during development, but I need a WAR for deployment.

I've followed this article about converting from a JAR to WAR Spring Boot Gradle build.

However, right now, everytime I switch the builds from one to the other, I have to comment and uncomment the specific parts of the build file.

Is there a cleaner way of handling allowing for both a JAR and WAR build?

like image 922
Steve Avatar asked Aug 28 '14 00:08

Steve


People also ask

What is Spring Boot WAR?

Spring boot war is defined as creating packaging of application as a war file. As we know that default packaging of the application is jar is deployed on tomcat server. We can also generate war file deployment of spring boot applications by using tomcat, JBoss, and weblogic server instances.

Does Spring Boot use WAR?

If you use the Spring Boot build tools, marking the embedded servlet container dependency as provided produces an executable war file with the provided dependencies packaged in a lib-provided directory.

What is difference between Spring Boot jar and WAR?

JAR files allow us to package multiple files in order to use it as a library, plugin, or any kind of application. On the other hand, WAR files are used only for web applications. The structure of the archives is also different. We can create a JAR with any desired structure.


1 Answers

The war that gets build for deployment (that is if you added the spring-boot maven plugin) is just as runnable as a jar file.

java -jar mywar.war

And presto it starts with an embedded server, you can deploy the same war to your server and then it doesn't use an embedded server.

like image 129
M. Deinum Avatar answered Sep 28 '22 06:09

M. Deinum