Are you starting with your first Spring MVC example and wondering how to include all Spring MVC dependencies into your project?
Sometime back I’ve written a complete article on HelloWorld Spring MVC tutorial. It is THE complete Java tutorial available for you to use. While working with some of my friends and users, I came to know that it would be also handy to identify how many Spring MVC .jar files
do they have to import into project? In other words, how many maven dependencies
if it’s maven project.
Let’s get started:
Step-1
In Eclipse, click on
- File
- New
- Maven Project
Step-2
Choose default Workspace location
Step-3
- Select Group Id:
org.apache.maven.archetypes
.
Step-4
- Provide Group Id:
crunchify.com
- Provide Artifact Id:
CrunchifyFirstSpringMvcExample
- Click on Finish
Step-5
You should see your maven project into Eclipse now.
Step-6
As maven project comes with default junit dependency you just have to include Spring MVC related dependencies. Open pom.xml
file and add below dependencies.
<dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <!-- spring-context which provides core functionality --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>4.1.6.RELEASE</version> </dependency> <!-- The spring-aop module provides an AOP Alliance-compliant aspect-oriented programming implementation allowing you to define --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>4.1.6.RELEASE</version> </dependency> <!-- The spring-webmvc module (also known as the Web-Servlet module) contains Spring’s model-view-controller (MVC) and REST Web Services implementation for web applications --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>4.1.6.RELEASE</version> </dependency> <!-- The spring-web module provides basic web-oriented integration features such as multipart file upload functionality and the initialization of the IoC container using Servlet listeners and a web-oriented application context --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>4.1.6.RELEASE</version> </dependency> </dependencies>
Now you are all set with your first Spring MVC project.