Maven/eclipse Build SSM (spring+spring Mvc+mybatis)

Source: Internet
Author: User
Tags apache download

Maven/eclipse Build SSM (spring+spring Mvc+mybatis)

Objective

The purpose of this article is to use MAVEN to build the SSM environment, and the specific content of MAVEN, you can read "Maven combat." In fact, there are a lot of articles in this area, so why do I have to build wheels again? I just want to record my own practice process, attached to others for reference. For other people's blog, see is good, if can pay the practice, it is better!

MAVEN Installation

The installation process is quite simple, go to Apache download Apache-maven Zip package, extract into a directory, such as

Next, configure the Windows environment, right-click My Computer--"Properties--" Advanced system settings--"Environment variables--" System variables--"new, such as

Is the MAVEN home directory you unzipped, and then edit the path of the system variable,

In fact, with the configuration of the Java environment is the same, the last few consecutive confirmed after the good, these several certain points, otherwise the configuration will not be saved, and will not take effect! Home path Be sure to write your own, don't move me! The path is best copied, and the manual input is too error-prone.

Next verify that the environment is configured successfully, open the command line, enter MVN-V if the message appears, then congratulations, the configuration is successful! Of course, the information may be slightly different, such as the version of the difference, these do not care.

Eclipse (Java EE edition) integrates maven

In general, the new eclipse is already integrated with MAVEN, if not installed, click on the Eclipse menu bar help->eclipse Marketplace search keyword maven to the plugin Maven integration for Eclipse and click Install, then replace the eclipse-integrated maven with our own, instead of the eclipse-brought, reposition it, click Preference, Maven, window installation, add to settings such as

Setup is complete, then eclipse configuration maven is done, and the MyEclipse configuration is the same as this one.

Create the SSM Project

Select Create Maven Project Select File--new--and other, select Maven---MAVEN project in the new window, and click Next, as

Select the project path, for example, then next

  

Select the project type Select the artifact ID for Maven-archetype-webapp, as

Enter the group ID and Artifact ID, as well as the package, what the group ID and Artifact ID represent, and you can read "Maven combat", group ID is equivalent to an organization, and Artifact The ID is equivalent to a specific project under this organization, and Packege will generate a default name based on your group ID and artifact ID, which can be used by default, as

After the dot finish, the project structure

If the directory structure is different from the above, then it is good to change the perspective to Java mode. The above directory structure is a little bit different from the standard MAVEN web structure, with one less folder Src/test/resources, we created it manually, right-click on the root of the project by clicking New---Source folder, to build this folders, such as:

After finish, the project structure diagram is as follows:

Turn the project into a Dynamic Web project right-click Project, Properties-"Project Facets, click Convert to faceted fro, tick the dynamic web Module, and set version to 2.3." (3.0 for Java7).

Set up Deployment assemblies (Web Deployment Assembly)
After the above step is set up, click OK, then right button project, select Properties----"Deployment Assembly, such as

The list here is the path to the file publication when the project is deployed.

(1) We delete the two items of test, because tests are used for testing and do not need to be deployed.

(2) Set the Maven jar package to be published under Lib.

ADD, Javabuild Path Entries, Maven Dependencies, Finish

Setup Complete

Building a framework

Add the required jar packages to the pom.xml, such as

View Code

If the dependence does not know how to write, such as GroupID, Artifactid, version does not know what to fill, then directly on the http://search.maven.org/search, corresponding to fill it out, such as

Save Pom.xml,maven will help us to download all of our configured jar package, jar package depends on the jar package will be automatically downloaded, is not very convenient! Of course, this download may take a long time, do not hurry, when the percentage of eclipse in the lower right corner of the progress is not available, the download is OK. After the jar package is downloaded, the project structure is shown below

Configuration file

Xml

View Code

Spring.xml

View Code

Mybatis-spring.xml

View Code

Spring-mvc.xml

View Code

Mybatis-config.xml

View Code

Log4j.properties

View Code

Mysqldb.properties

View Code

The project structure diagram is as follows

Java files and JSP files

Personcontroller.java

View Code

Personmapper.java

View Code

Personmapper.xml

View Code

Person.java

View Code

Ipersonservice.java

View Code

Personserviceimpl.java

View Code

showperson.jsp

View Code

MySQL database table

Final effect

  

So congratulations, congratulations to me, build the SSM success!

Something

The heart of the small partner should have found that the front Windows configuration maven and we use Eclipse to build the SSM does not have a little relationship, indeed, and SSM build no egg relationship, I write why, is sometimes we do not use IDE tools, And with the DOS command to build our project with MAVEN, then Windows configuration maven needs it!

Categories: Maven, MyBatis, spring MVC

Maven/eclipse Build SSM (spring+spring Mvc+mybatis)

Related Article

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.