I created a simple spring mvc application following a springboot springmvc with gradle example.
Below is the structure. src/main/java - This is where all the code base is there. src/main/resources - This is where all the resources/templates are there.
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class Application { public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
And just writing the above class and with zero configurations, I was able to launch my spring-mvc web application (which is very cool). (through commands gradlew build and gradlew bootrun) But coming from a traditional web application development and deployment background, I am wondering how to create a war file out of this and deploy that into a tomcat webapps folder.
Also, where to keep all the new resources (like js files, css, etc.). We would generally have a WEB-INF folder where we keep them, but what to do here.
meskobalazs answered your question about the resources when building a war deployment (but notice that src/main/webapp
is not read as a resource folder in a jar deployment, you have to add it as a resource in this case).
When you want to change your Spring-Boot app to a web deployment you basically have to do two things:
Further details can be found on the Spring-Boot documentation site
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With