3
votes

My Application : backbone.js based frontend, RESTFUL webservices based backend. I have configured a spring boot standalone application for the above spec. I have used configured spring security for token based authentication. The static content too is bundled inside the jar and served by the embedded tomcat server.

My Question : I've previously seen project setups where front-end and backend are cleanly separated by having webserver - app server setup. Now here I am bound to put both of them inside a bundle. Separation Of Concerns? Or is it better to configure spring boot to create a war for me? I feel spring boot isn't meant for creating wars ..

2
Why? What is creating a WAR buying you? Spring Boot lets you deploy everything in a single package. That's what you need. Don't worry about notions of purity and cleanliness. - duffymo
I got this doubt when I saw all my static pages go through the WebSecurityConfigurerAdapter that I used ... Might make my tomcat slow right? Here is that question : stackoverflow.com/questions/29074285/… - David Nimmagadda
If you create a WAR, you still have all resources in the WAR. Spring Boot doesn't prevent you from putting your static resources on your webserver and configure the web server to use its resources instead of forwarding the request to the Spring Boot app (Tomcat is not a web server, it is a servlet container). - dunni
Thanks for the suggestions guys ... that makes sense, I'll leave my standalone spring boot app as it is and configure an apache web server before it and put my static content there ... - David Nimmagadda

2 Answers

1
votes

You can change packaging from jar to war. But in jar packaging there is one limitation that you can't use JSP Servlets technology, while war support that. To deploy war you have to write descriptor file, war.xml and also you need a server to deploy war, while jar as you know Spring boot gives an inbuilt server. I hope my answer helped.

1
votes

If you are using gradle as a build tool, you can simply use

apply plugin: 'war'

gradle war

to create a war