Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Assistance need to get Spring MVC project going with IntelliJ IDEA

So I downloaded a trial of idea ultimate, and I want to get spring mvc going with tomcat.

So I setup a new project, configured it to use sun jdk.

I chose a spring application, and it created and downloaded the following:

http://img15.imageshack.us/img15/4853/idealspring1.png

I don't see any spring-mvc libraries, are they included in there or do I have to do something about that?

Can someone outline what I have to do to get this to build like a spring mvc web application?

like image 693
Blankman Avatar asked Jun 25 '10 15:06

Blankman


1 Answers

I find that the best way to start a new IDEA project is to use the Maven. This allows you to easily build your project without launching the IDE, automatically maintaining all libraries for you.

"Create project from scratch", then select "Maven module" in the next screen. Click on "Create from archetype" and select the "maven-archetype-webapp". This will give you a basic Maven layout which builds a simple WAR file.

Now to add the Spring libraries, open the Maven build file - pom.xml - and insert a new dependency on the Spring MVC framework:

   <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>3.0.0.RELEASE</version>
    </dependency>

From here, you can follow the Spring MVC reference documentation - add the Dispatcher Servlet and Context Listener to web.xml, a Spring XML context and so on.

Something else you might find useful is the Maven Jetty plugin. Once configured, you can run your app by simply typing "mvn jetty:run" at the command prompt (or launching it from within the IDE). Maven will fetch all that's required and deploy the app for you, no need for an external app server setup for quick testing.

like image 115
Pavel Avatar answered Jan 04 '23 12:01

Pavel