开发者

Assistance need to get Spring MVC project going with IntelliJ IDEA

开发者 https://www.devze.com 2023-01-04 22:56 出处:网络
So I downloaded a trial of idea ultimate, and I want开发者_运维技巧 to get spring mvc going with tomcat.

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:

Assistance need to get Spring MVC project going with IntelliJ IDEA

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?


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.


I'm not sure if your setup would be identical to mine, but when I downloaded spring-framework-2.5.6 there were jar files named spring-web.jar, spring-webmvc.jar, etc. in the \dist\modules subfolders. The tutorial indicated at least spring-webmvc.jar should be in your WEB-INF/lib folder.

This tutorial optionally used eclipse, but might be helpful anyways, especially getting started:

http://static.springsource.org/docs/Spring-MVC-step-by-step/


I think there are specific JARs for the Spring MVC stuff. Basically when you download the latest Spring Framework and you extract the zip you need to go to the dist folder and add the org.springframework.web.jar and org.springframework.web.servlet.jar/org.springframework.portlet.jar to your project. I'm pretty sure that the servlet/portlet jars will have your MVC specific classes.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号