A web-based MyBatis project

Source: Internet
Author: User

  1. The need to introduce Apache.commons.dbcp-1.2.2.osgi.jar and Org.apache.commons.pool-1.5.3.jar to provide JDBC access;
  2. Need Org.springframework.transaction-3.0.5.release.jar to provide Daosupport class;
  3. Org.springframework.jdbc-3.0.5.release.jar is used to provide autoware tag bindings when starting mybatis bindings;
  4. There are also database-driven classes;
ModulePanel, select the project default path is root,but the default should be project name. then the global search "ROOT", only to find the original in the. Settings folder There is a org.eclipse.wst.common.component file, which defines the <?xml version= "1.0" encoding= "UTF-8"? ><project-modules id= "Modulecoreid" project-version= "1.5.0" > <        Wb-module deploy-name= "zcm" > <wb-resource deploy-path= "/" source-path= "/target/m2e-wtp/web-resources"/> <wb-resource deploy-path= "/" source-path= "/src/main/webapp" tag= "Defaultrootsource"/> <wb-resource de Ploy-path= "/web-inf/classes" source-path= "/src/main/java"/> <wb-resource deploy-path= "/WEB-INF/classes" sour Ce-path= "/src/main/resources"/> <property name= "Context-root" value= "ROOT "/><property name= "Java-output-path" value= "/zcm/target/classes"/> </wb-module></project-modules>only to know, the original web project pre-name is specified here. As to why it would be root, maybe because when I came down from SVN, I would create an Eclipse project, which was created as root by default,because the default name for other manually created Web projects is the project name. The solution to this problem requires two aspects:
    1. Using Eclipse 's default tomcat7, verify that the JDK version is Jdk7, which was previously incorrectly specified as a JDK

in the Add Server interface, click Configure Runtime Environments Click Edit ...Follow the JRE version Cleanis to clean work.MyBatisthe resultmap in mapper is a custom type, avoid creating a Vo class, but you can define a temporary object for a query in mapper XML. The object is then associated with the field of an entity class. If the field of the query result can correspond to the entity class one by one can be specified by the development of Resulttype , in fact, in the specified (bean) sqlsessionfactory typealiasespackage field, You have specified an alias that can be omitted so that the class name is written directly in the Resulttype (no previous namespace required) <Bean id= "sqlsessionfactory" class="Org.mybatis.spring.SqlSessionFactoryBean"> <property name= "dataSource" ref="DataSource" /> <property name= "configlocation" value="Classpath:sqlmapConfig.xml"></ Property> <property name= "mapperlocations" value="Classpath:mapper/*mapper.xml"> </Property> < name= "typealiasespackage" value= "com.zcm.mall.vo"></Property > </Bean> or, specify it in the MyBatis configuration file: <? XML version= "1.0" encoding="UTF-8"?> <! DOCTYPE configuration public "-//mybatis.org//dtd Config 3.0//en" "http://mybatis.org/dtd/ Mybatis-3-config.dtd "> <configuration> <typealiases> <package name="Com.zcm.mall.vo"/> </typealiases> </configuration>

A web-based MyBatis project

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.