简体   繁体   中英

How to create Spring MVC application with Maven structure in Intellij IDEA 13.1?

I want to to create new Spring MVC project in Maven structure using Intellij IDEA but can't do that. actually i want to create project like mkyong.com samples, likethis .

NOTE

I'm new to Intellij IDEA and want to create new project not import from existing project.

All you need to do is the following.

Click File -> New Project and then:

First add this Maven archetype (from the button on top right)

在此处输入图片说明

That archetype will help you bootstrap the project by providing some Spring configuration code and must be present in your local Maven repository (directions are provided on how to do that in the link I sent - it's very easy).

After adding the archetype just do like in the following screenshot:

在此处输入图片说明

The next screen just asks you for the the GroupId , ArtifactId and Version of your project. The following screens are trivial.

That's it!

Note that you can use any archetype you like (although the one I supplied seems to be very much up to date). If you find a better one than the one I supplied, feel free to use it. You can also write your own without too much trouble.

Update as per comment for IntelliJ 15 :

Same instructions apply and here's a view from it:

在此处输入图片说明

Also note that Spring Initializr has been added in the same New Project screen that is becoming the de-facto way of initialising Spring Boot applications.


(initial post)

In IntelliJ 13 Ultimate Edition it's very simple since the template is built-in:

File > New Project > Spring > Create project from template > Spring MVC

在此处输入图片说明在此处输入图片说明

The above suggestions didn't work for me. What I did is Creating MVC project straight up with Maven, based on the archtype :

http://kolorobot.github.io/spring-mvc-quickstart-archetype

The command is:

mvn archetype:generate \
    -DarchetypeGroupId=pl.codeleak \
    -DarchetypeArtifactId=spring-mvc-quickstart \
    -DarchetypeVersion=1.0.0 \
    -DgroupId=my.groupid \
    -DartifactId=my-artifactId \
    -Dversion=version \
    -DarchetypeRepository=http://kolorobot.github.io/spring-mvc-quickstart-archetype

Or, if you want to just Copy-Paste it to shell or cmd in one line:

mvn archetype:generate -DarchetypeGroupId=pl.codeleak -DarchetypeArtifactId=spring-mvc-quickstart -DarchetypeVersion=1.0.0 -DgroupId=my.groupid -DartifactId=my-artifactId -Dversion=version -DarchetypeRepository=http://kolorobot.github.io/spring-mvc-quickstart-archetype

When DgroupId , DartifactId & Dversion are the groupId , artifactId and version of your project.

It will generate a full working maven project.

The next step is just to import the maven project to IntellijIDEA.

As for Version 14.1.4:

  1. File -> New -> Project from Existing Sources... and choose the Project you generated.
  2. Check the Import project from external model and choose Maven .
  3. At this point there will be more configurations, but you can just click Next & Finish .

To run the project in your browser you would need to install and configure Apache Tomcat .

IntelliJ and Tomcat.. Howto..?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM