The article describes steps that are required to build the a Spring MVC web application project using Gradle tool.
Make sure you have maven-based web application folder. We recommend you to check our article published on different possible layouts of web application folders. As a recap, following is how the web application folder structure would look like:
Create a gradle script in the root folder. Name it as build.gradle. Following is how the gradle script would look like:
apply plugin: 'java'
apply plugin: 'war'
repositories {
flatDir { dirs "src/main/webapp/WEB-INF/lib" }
mavenCentral()
}
dependencies {
compile 'org.springframework:spring-webmvc:4.0.3.RELEASE'
compile 'org.springframework:spring-core:4.0.3.RELEASE'
compile 'org.springframework:spring-aop:4.0.3.RELEASE'
compile 'org.springframework:spring-web:4.0.3.RELEASE'
compile 'org.springframework:spring-beans:4.0.3.RELEASE'
compile 'org.springframework:spring-context:4.0.3.RELEASE'
compile 'org.springframework:spring-tx:4.0.3.RELEASE'
compile 'org.hibernate:hibernate-core:4.3.5.FINAL'
compile 'org.hibernate:hibernate-jpa:2.1-api-1.0.0.FINAL'
}
war {
webInf { from 'src/main/webapp/WEB-INF'} // adds a file-set to the WEB-INF dir.
classpath fileTree('src/main/webapp/WEB-INF/lib') // adds a file-set to the WEB-INF/lib dir.
webXml = file('src/main/webapp/WEB-INF/web.xml') // copies a file to WEB-INF/web.xml
from('src/main/webapp') { include ('bootstrap/css/*.css', 'bootstrap/js/*.js', 'bootstrap/img/*.*') }
}
task deploy (dependsOn: war){
copy {
from "build/libs"
into "D:/Apache Software Foundation/Tomcat 8.0/webapps"
include "*.war"
}
}
Last step is to build the web application. Go to root folder of web application. Execute the command “gradle war” to build. Optionally, execute “gradle deploy” and the web application will be built and the war file will be deployed in tomcat webapps folder.
Last updated: 25th Jan, 2025 Have you ever wondered how to seamlessly integrate the vast…
Hey there! As I venture into building agentic MEAN apps with LangChain.js, I wanted to…
Software-as-a-Service (SaaS) providers have long relied on traditional chatbot solutions like AWS Lex and Google…
Retrieval-Augmented Generation (RAG) is an innovative generative AI method that combines retrieval-based search with large…
The combination of Retrieval-Augmented Generation (RAG) and powerful language models enables the development of sophisticated…
Have you ever wondered how to use OpenAI APIs to create custom chatbots? With advancements…