Reputation: 1765
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.
Upvotes: 8
Views: 3078
Reputation: 1127
If you are using Maven project you need to modify pom.xml to change the packaging to war, as follows
<packaging>war</packaging>
And If you are using Gradle project you need to modify build.gradle as follows
apply plugin: 'war'
Once you build project it will create war file, so you can easily deploy in any tomcat server webapps folder
Upvotes: 0
Reputation: 2809
Spring Boot include Tomcat container.
You have to remove external Tomcat to deploy your project
Upvotes: 0
Reputation: 19421
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
Upvotes: 1