Add Springmvc and MyBatis for MAVEN project on Eclipse to implement the call to the database package

Source: Internet
Author: User
Tags log4j

Background

To implement a cross-database package call at work, back at the front end of the JSP, the project is only Maven, so refer to andyの notes to see what updates you need to combine your project to achieve a simple function.

1. Maven

Although Maven has been embedded in the project in Eclipse, there is a single Maven tool that can be installed separately in the system, referring to the setup and introduction of Andy's MAVEN environment.

In the Middle of the problem "-dmaven.multimoduleprojectdirectory system propery is not set. Check $M 2_home environment variable and MVN script match. "that can be resolved here.

2, Generate Mybatis

After loading dependence, use generator to automatically generate the mapping profile information by Andy's MyBatis to generate the configuration file. The Bxxxxxlxxxx.java,bxxxxxlxxxxmapper.java and Bxxxxxlxxxxmapper.xml were correctly generated and placed in \src\main\java\com\xxxxx\xxx\domain, Src\main\java\com\xxxxx\xxx\mapper and the Src\main\java\com\xxxxx\xxx\mapper\sqlmaps directory.

3. Introduce Spring and configure

Follow the procedure prompts to change the Pom.xml file for the new jar package that is about to be introduced

        <!--spring Add by Steven--<dependency> <groupid>org.springframework</ Groupid> <artifactId>spring-core</artifactId> <version>3.1.1.release</ve rsion> </dependency> <dependency> <groupid>org.springframework</group Id> <artifactId>spring-beans</artifactId> <version>3.1.1.release</versio n> </dependency> <dependency> &LT;GROUPID&GT;ORG.SPRINGFRAMEWORK&LT;/GROUPID&G              T <artifactId>spring-context</artifactId> <version>3.1.1.RELEASE</version> &lt ;/dependency> <dependency> <groupId>org.springframework</groupId> &L T;artifactid>spring-tx</artifactid> <version>3.1.1.RELEASE</version> </depen Dency> <dependency> <groupId>org.springframework</groupId> <artifactid>spring-w eb</artifactid> <version>3.1.1.RELEASE</version> </dependency> <de Pendency> <groupId>org.springframework</groupId> <artifactid>spring-webmvc& lt;/artifactid> <version>3.1.1.RELEASE</version> </dependency> <depen Dency> <groupId>org.springframework</groupId> <artifactid>spring-jdbc</a rtifactid> <version>3.1.1.RELEASE</version> </dependency> <dependency > <groupId>org.springframework</groupId> <artifactid>spring-test</artifa Ctid> <version>3.1.1.RELEASE</version> <scope>test</scope> & lt;/dependency&Gt              <!--mybatis Add by Steven--<dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.1.0</version> </depe ndency> <!--mybatis Spring Add by Steven--<dependency> &LT;GROUPID&GT;ORG.M Ybatis</groupid> <artifactId>mybatis-spring</artifactId> <version>1.1.1&              Lt;/version> </dependency> <!--log4j Add by Steven----<dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> &LT;VERSION&G        T;1.2.17</version> </dependency> <!--struts2 Add by Steven----<dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> &L T;version>2.3.16.3</version> </dependency> <dependency> <groupid>org.apache.struts</         Groupid> <artifactId>struts2-json-plugin</artifactId> <version>2.3.16.3</version> </dependency> <dependency> <groupId>org.apache.struts</groupId> <a Rtifactid>struts2-spring-plugin</artifactid> <version>2.3.16.3</version> </dependenc Y> <!--Gson Add by Steven--<dependency> <groupid>com.google.code.gson&lt ;/groupid> <artifactId>gson</artifactId> <version>2.1</version> &L T;/dependency> <!--c3p0 Add by Steven--<dependency> <groupid>com.mchange        </groupId> <artifactId>c3p0</artifactId> <version>0.9.5</version>  </dependency>      <!--aspectjweaver Add by Steven--<dependency> &LT;GROUPID&GT;ORG.ASPECTJ&LT;/GROUPID&G        T        <artifactId>aspectjweaver</artifactId> <version>1.6.8</version> </dependency> <!--cglib Add by Steven--<dependency> <groupId>cglib</groupId> &lt ;artifactid>cglib</artifactid> <version>2.2.2</version> </dependency&gt, ... & lt;resources>         <resource>             <directory>src/main/resource</directory>     & nbsp;    <includes>             < include>*.xml</include>            <include >*.properties</include>          </includes>     </resource>   & nbsp </resources> 
And the following resources references need to be added to the build node to help MAVEN load the required struts and mybatisconfig configuration files.



Add Springmvc and MyBatis for MAVEN project on Eclipse to implement the call to the database package

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.