Building IntelliJ IDEA+MAVEN+JETTY+SPRINGMVC Development Environment (i)

Source: Internet
Author: User
Tags xmlns


Eclipse has been used in the past, occasionally using MyEclipse, and now the idea is being used due to work needs. Because it is also just contact with this development tool, in the groping stage, while learning to write an environment to build a blog, share with you.


First, the new project

1. Open the Idea tool and select New Project File-> new. Choose Maven, choose the project JDK version, I use 1.8 (screenshot is 1.7), on the right of the selection box tick the create from archetype, and select the appropriate option, as shown below, select OK Next:

2, here need to fill in GroupID and Artifactid and version, these three properties are intended to identify the uniqueness of your project, For example, Jetty GroupID is Org.eclipse.jetty, that is, it is an Eclipse organization project, Artifactid is Jetty-server, the project name is Jetty-server, and I currently use version is 9.4.0.v20161208 。 These are only available at the time of release, so you can fill them out, and then click Next:


3. Open Maven home directory and discover that IntelliJ idea has integrated maven 2 and MAVEN 32 versions, as well as a local Maven version, where we choose the MAVEN version we installed and click Next.

4, fill in the project name and project save path, click Finish to complete the project creation.


5. After finish, MAVEN will generate the Web project in the background, which will take a certain amount of time, depending on the network environment, experience found that the newer version of the MAVEN project generated faster, using idea integrated maven may wait for a long period of practice.

The following figure is the initial schema of a project (initializing), red box 1 is the file schema of the project, because the file schema is not complete, because it is initializing, red Box 2 is the console, according to the information displayed can know that the MAVEN project is being created; red Box 3 is a MAVEN compilation option. After selecting Enable-auto-import, each time you modify the MAVEN Profile Pop.xml project will automatically import the jar package (will not be asked again), some students may choose this after the project will likely appear after the situation, so now for the first choice, import changes, this is every When you finish modifying the Pop.xml file project, you are asked to import the jar package. This prompt will appear as soon as you have modified the Pop.xml file, so you can choose one here.


After the MAVEN project is built, the entire project schema is shown below. A little bit about the Web project students will know the role of each folder, I do not explain here.


At this time may have classmates will have questions, how and the previous project is not the same ah, there is no Java this folder. Yes, now there are no folders to store Java source code, so we need to create one manually:

Press Ctrl+alt+shift+s, or file->project structure to check the project structure to see if it is set correctly.


Confirm that no problem after selecting modules, on the main folder, right-click on the new folder, named Java (this name is arbitrary)


Now create a Java file is just a normal folder, you need to set him as a source folder, select the Java folder, and then select the above source, the project will be set to the right of the schema changes

At this point, the initialization of a Web application is working and completing.


Second, MAVEN auto-import jar Package

MAVEN-managed projects now that we have created, we now need to import the jar packages needed for the project through MAVEN. The advantage of MAVEN is that we don't need to go to the network to find a jar, just need to use the jar package name and version number in the configuration, MAVEN will automatically download from his jar package warehouse, the relevant configuration in the inside also have demo, Just copy the demo of the corresponding jar package to the pop.xml of the project.


The project configuration code is as follows:

<project xmlns= "http://maven.apache.org/POM/4.0.0" xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi: schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" > <modelversion >4.0.0</modelVersion> <groupId>com.promonkey</groupId> <artifactid>springmvcdemo</ artifactid> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name> Springmvcdemo Maven webapp</name> <url>http://maven.apache.org</url> <!--set JAR package version--&LT;PR Operties> <spring.version>4.3.2.RELEASE</spring.version> <mybatis.version>3.3.0</mybatis .version> </properties> <dependencies> <!--unit Test Jar Pack--<dependency> <grou
      Pid>junit</groupid> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependenCy> <!--SPRINGMVC needed jar--<dependency> <groupid>org.springframework</groupid&
          Gt <artifactId>spring-context</artifactId> <version>${spring.version}</version> </ Dependency> <!--HTTPS://MVNREPOSITORY.COM/ARTIFACT/ORG.SPRINGFRAMEWORK/SPRING-WEBMVC-<dependency
      > <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${spring.version}</version> </dependency> <!--HTTPS://MVNREPOSITORY.COM/ARTIFAC
      T/org.springframework/spring-web-<dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${spring.version}</version> </depend Ency> <!--MyBatis Required Jar--<dependency> <groupId>org.mybatis</groupId> <artif Actid>mYbatis</artifactid> <version>${mybatis.version}</version> </dependency> <!--database Jar Package-- > <dependency> <groupId>mysql</groupId> <artifactid>mysql-connector-java</artifact id> <version>5.1.38</version> </dependency> </dependencies> <build> <f inalname>springmvcdemo</finalname> <plugins> <plugin> <groupid>or
              G.apache.maven.plugins</groupid> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</targe
          T> </configuration> </plugin> <!--jetty Plug-in--<plugin> <groupId>org.mortbay.jetty</groupId> &LT;ARTIFACTID&GT;MAVEN-JETTY-PLUGIN&LT;/ARTIFACTID&G
          T <configuration> <stopPort>9988</stopPort> <stopKey>foo</stopKey> &L T;scanintervalseconds>5</scanintervalseconds> <connectors> <!--<connector I mplementation= "Org.eclipse.jetty.server.nio.SelectChannelConnector" >--> <connector implementation= " Org.mortbay.jetty.nio.SelectChannelConnector "> <port>8088</port> <maxidl etime>60000</maxidletime> </connector> </connectors> <webapp Config> <contextPath>/</contextPath> <defaultsdescriptor></defaultsdes criptor> </webAppConfig> </configuration> </plugin> </plugins > </build> </project>

After the configuration is complete, a message pops up in the lower-left corner, whether to import pop.xml changes, or, if not, click on the Maven update on the right, so Maven will import the jar package:


Once the jar package has been imported, you can view it in the file schema on the left:


At this point, the jar packages required for the project are all imported. At this point, you can check the project schema on the right, whether there are jetty plugins in the plug-in (Plugins), and if so, you can use jetty.


Next: Build IntelliJ IDEA+MAVEN+JETTY+SPRINGMVC Development Environment (II)


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.