Assistance need to get Spring MVC project going with IntelliJ IDEA

前端 未结 3 1277
孤城傲影
孤城傲影 2021-01-31 11:53

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 sprin

相关标签:
3条回答
  • 2021-01-31 12:25

    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 讨论(0)
  • 2021-01-31 12:26

    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/

    0 讨论(0)
  • 2021-01-31 12:42

    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.

    0 讨论(0)
提交回复
热议问题