Develop SPRINGMVC website using IntelliJ idea (i) Development environment

Source: Internet
Author: User
Tags windows download

Original: Using IntelliJ idea to develop SPRINGMVC website (i) Development environment

Summary mainly explain the initial development environment to build, Maven's simple teaching. Idea Spring MVC

Catalogue [-]

  • The article has made a certain update for idea 15, some updates are more important, please re-read the article and download the latest source code.
  • Objective
  • First, the relevant environment
  • II. installation of local maven and Tomcat
  • 1. Download and install the local maven???
  • 2. Download and install the local tomcat
  • Iii. creating a MAVEN Web project
  • Iv. maven Auto-import jar Package
  • Reprint Please specify the Source: Gaussic (a graduate student who is committed to AI research but has to juggle projects).

    Visit GitHub to download the latest source: Https://github.com/gaussic/SpringMVCDemo

    The article has made a certain update for idea 15, some updates are more important, please re-read the article and download the latest source code. Objective

    Because of the recent academic work, project development-related work did not take much time, resulting in the update of this article stopped for a long time. Now at the request of everyone, fill the rest, hope to bring you some help. Due to the time, there are some updates on the development environment, but it does not cause much impact.

    Recently in the development of an online education platform website, according to senior's suggestion to use SPRINGMVC to engage. Before the springmvc of the cognition of 0, online access to various materials, found a variety of configurations have, the article is called a disorderly ah, I think some articles or do not send a better, simply fraught delay time. Recently, through my brother's online collection of some development experience, found on the IntelliJ website of this article "Getting Started with Springmvc, Hibernate and JSON" (the link has been invalidated, the content will be reflected in the text), Plus look at the hole teacher's "springmvc video Tutorial ", there is a clairvoyant feeling, the whole way instantly through, development speed index type rise. Now put some relevant experience in the development process out.

    First, the relevant environment

    -Intellij Idea 15.0.4 Ultimate

    -Tomcat 7.0.68

    -JDK 1.7.0_80

    -Spring 3.2.0

    -MYSQL 5.7

    -Maven 3.3.9

    -Bootstrap 3.3.5

    The above is what I need to do this demo, of course, some are optional, the version is also controllable. For example, if you are not used to Maven, you can go to the official website to download the jar package and then import their own projects, if you want to learn maven can see "maven Video tutorial " (accidentally found, the teacher did the video is very good, recommend the following), Instead of fully learning maven, knowing the meaning and then looking for IntelliJ idea how to configure MAVEN related articles is enough.

    There are bootstrap, pure personal cleanliness, do not need this can go.

    In advance, make sure that IntelliJ idea, Tomcat, MySQL, and JDK are all installed. The words of Maven and bootstrap can be there. The former in order to make the guide package easier, the latter in order to make the page more beautiful. In addition, there are a lot of tutorials on the JDK and MySQL installation web, which is not an introduction to save space. Don't say much nonsense, start formally.

    II. installation of local maven and Tomcat

    Note: If you use the IntelliJ idea integrated maven 3.0.5, you can ignore this step installation.

    1. Download and install local maven

    Click on "Apache-maven official website " to enter the website, click on the left download option:

    Go to the download page, pull down to find the current version is 3.3.3, click on the red box below the apache-maven-3.3.9-bin.zip can download, download and unzip to the appropriate directory:

    New system Variable maven_home: Maven install directory:

    Add to Path:%maven_home%\bin;

    Entering mvn-v in cmd, if shown below, indicates that the local MAVEN configuration is complete:

    2. Download and install the local tomcat

    Go to the Tomcat website and click on the download Tomcat7.0 on the left to enter the Tomcat download page:

    64-bit version of Windows download 64-bit Windows Zip (PGP, MD5, SHA1), unzip to the desired directory:

    After unzipping to the \bin\ directory, run Startup.bat, as shown below, if the server startup in XXXX Ms indicates that the Tomcat installation was successful.

    Iii. creating a MAVEN Web project

    With so much in front, almost everything is guaranteed (provided you have the JDK installed). Now get to the point, how to create a Web project. For developers who don't use Maven, you can build a simple Web project directly. If you use Maven, follow the diagram.

    Menu File->new Project to enter the interface, first select the left column maven, and then configure the JDK (generally if you have added a JDK before will be automatically populated, if not added, click Next to the New JDK directory to import). Tick "Create from archetype", then select the 4 blue position webapp, click Next to enter the following screen:

    Here you need to fill in GroupID and Artifactid and version, these three properties are designed to identify the uniqueness of your project, For example, Tomcat's GroupID is Org.apache, which is the Apache organization project, Artifactid is Tomcat, the project name is Tomcat, and I am currently using version 7.0.68. These are only useful at the time of release, so you can fill in the blanks and fill in the following page.

    Open Maven Home directory to discover that IntelliJ idea has integrated maven 2 and MAVEN 32 versions, and if you use the default integrated maven, choose buldled (Maven 3) and click Next.

    We can also import the newer MAVEN version of the new installation locally, click on the blue arrow to the right ... button to import the MAVEN path, click Next:

    Fill in the project name, select the project save path, click Finish:

    With the following interface, MAVEN builds the Web project in the background, which will take some time, depending on the network environment, and experience has found that it is faster to build with a newer version of MAVEN projects, and MAVEN with idea integration may be waiting for a long practice.

    The file structure of the project is shown in the red box on the left. It can be found that it creates a Recources folder under Src/main, which is typically used to hold some resource files, and a WebApp folder for Web configuration files and JSP pages, which has formed an original Web application. Select the Enable-auto-import of the red box on the right, you can automatically download and import the jar package after each modification of pom.xml, which is detailed later.

    Iv. maven Auto-import jar Package

    Since we are going to develop with SPRINGMVC, there is no doubt about the Springmvc jar package. If you do not use MAVEN, then you need to go to the official website to download the relevant jar package, and then import into the project. Now with Maven, there's no need to surf the web for Jar packs. Specifically, I'm going to be one by one.

    Maven does a very simple job of automatically downloading the jar packages you need to be locally and then associating them with the project. All of Maven's jar packages are stored in a few central warehouses, and one of the most commonly used is maven Repository, which is what jar package you need, and it will get you from the warehouse. So how do you tell maven what jar packages are needed? Let's look at the engineering catalog, find a Pom.xml file (which is already in front of you when you've just created a project), and Maven is relying on it to define the requirements, the 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.gaussic</groupid>     <artifactId>springmvcdemo</artifactId>    < packaging>war</packaging>    <version>1.0-snapshot</version>     <name>springmvcdemo maven webapp</name>    <url >http://maven.apache.org</url>    <dependencies>         <dependency>             <groupid>junit</groupid>            <artifactid>junit</artifactid>             <version>3.8.1</version>             <scope>test</scope>         </dependency>    </dependencies>     <build>        <finalname>springmvcdemo </finalName>    </build></project>

    We can see that this file contains information such as the gropid of the project we defined earlier, which is the identity of the project and we do not want to change it. Focus on <dependencies> tags, translation is the meaning of "dependence", that is, the requirements of each package is called a dependent <depedency>, defined in <dependencies>. In each <depedency>, you need to provide the three necessary information for the GroupID, Artifactid, and version of the required jar package. For example above we see the introduction of a JUnit package, in the following format:

    <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version> ;3.8.1</version> <scope>test</scope></dependency>

    This is a unit test package that provides three basic information, and a 4th scope is not required for other packages. All jar packages are introduced in this format. So how to look at the 3 of these jar package information, perhaps the new contact is not very familiar with the developer, this time need to consult the warehouse. For example, we need to introduce the Spring core jar package Spring-core, open Maven Repository, search for Spring-core, and enter the following interface:

    Click into the Red box selected spring Core, as shown below, you can see the usage of each version:

    Select the latest version of 4.2.5.RELEASE, you can see its dependency notation as shown in the following red box:

    We'll copy it to the <dependencies> in Pom.xml:

    In this way, MAVEN will begin to download the jar package automatically to the local repository and then link it to your project, and after the download is complete, we expand the external Libraries in the project catalog:

    It can be found that although we only write a dependency, it imports two jar packages, that is, when importing a jar package, the jar package that is closely related to it is also imported.

    In addition to Spring-core, I also want to Spring-context, copy Spring-core <dependency>, Spring-core to Spring-context, as follows:

    <dependency> <groupId>org.springframework</groupId> <artifactid>spring-context</ Artifactid> <version>4.2.5.RELEASE</version></dependency>

    After the download is complete, see external Libraries, will not find, an instant import a lot of jar package (of course not an instant, it depends on your speed) it:

    This is the strength of MAVEN, and if you need to use SPRINGMVC to develop a website, simply remember the name of a few important packages and you can easily import all the packages into the project.

    To make a long story short, now we are going to develop SPRINGMVC, please turn your pom.xml into the following, of course, do not change your grupid and other information (from modelversion to the URL do not move):

    <properties> <spring.version>3.2.0.RELEASE</spring.version> <spring-data.version>1.2.0. Release</spring-data.version></properties>

    Please include the following dependencies in <dependencies>:

        <dependency>        <groupId> Org.springframework</groupid>        <artifactid> Spring-core</artifactid>        <version>${spring.version} </version>    </dependency>    <dependency>         <groupId>org.springframework</groupId>         <artifactId>spring-web</artifactId>         <version>${spring.version}</version>    </dependency>     <dependency>        <groupId> javax.servlet</groupid>        <artifactid>servlet-api< /artifactid>        <version>2.5</version>    </dependency>     <dependency>        <groupId> javax.servlet.jsp</groupid>        <artifactid>jsp-api< /artifactid>        <version>2.1</version>         <scope>provided</scope>    </dependency >    <dependency>        <groupId> Org.springframework</groupid>        <artifactid> spring-webmvc</artifactid>        <version>${ spring.version}</version>    </dependency>    < Dependency>        <groupid>org.springframework</groupid>         <artifactid>spring-test</artifactid>        <version >${spring.version}</version>        <scope>test</ scope>    </dependency>    <dependency>         <groupId>jstl</groupId>         <artifactId>jstl</artifactId>        < version>1.2</version>    </dependency>    < dependency>        <groupid>org.springframework.data</ Groupid>        <artifactid>spring-data-jpa</artifactid >        <version>${spring-data.version}</version>    </dependency>     <dependency>        <groupId> Org.hibernate.javax.persistence</groupid>        <artifactid >hibernate-jpa-2.0-api</artifactId>        <version> 1.0.0.final</version>    </dependency>    <dependency >        <groupId>org.hibernate</groupId>         <artifactId>hibernate-entitymanager</artifactId>         <version>3.6.10.final</version>    </ dependency>    <dependency>        < groupid>mysql</groupid>        <artifactId>mysql-connector-java</artifactId>         <version>5.1.34</version>    </ dependency>    <dependency>        < groupid>org.json</groupid>        <artifactid>json</ artifactid>        <version>20080701</version>     </dependency>

    We can see that, in addition to importing spring-related jar packages, there are some other packages that are useful, and we'll talk about them later. If you do not use MAVEN, download the relevant jar packages for spring, hibernate, MySQL, Jstl, Javax-servlet, JSON, etc. and import them into the project yourself. At this point, the import of the jar package is complete, we press ctrl+alt+shift+s, or file->project structure look at the project structure to see what the problem is:

    Since we are going to start writing the code, first make some configuration, select modules, create a new folder in the Springmvcdemo Src\main folder, named Java:

    Check the Java folder, click on the Make As:sources, the folder will be blue, to save Java code, press OK, end the configuration.

    (Open another article, see Using IntelliJ idea to send Springmvc website (ii)).

    Reprint Please specify the Source: Gaussic (a graduate student who is committed to AI research but has to juggle projects ).

    Develop SPRINGMVC website using IntelliJ idea (i) Development environment

    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.