mybatis core configuration file code

This is the core configuration file 
is created automatically generated configuration file maven on the line

<? Xml version = "1.0" encoding = "UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>mybatis01</groupId>
<artifactId>day806</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.4.5</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.32</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies>
</project>
这是数据库的链接的配置文件
Resources need to be placed inside
<?? xml Version = "1.0" encoding = "UTF-8"> 

! <DOCTYPE the Configuration the SYSTEM "http://mybatis.org/dtd/mybatis-3-config.dtd" the PUBLIC "- // mybatis.org/ / Config the DTD 3.0 // EN ">

- <Configuration>

<-! redistribute attribute file ->


<properties Resource =" the jdbc.properties "/>

<-! type alias mapping ->



- <typeAliases>

< ! - <typeAlias type = "cn.lijun.domain.User" alias = "ruiruri"> </ typeAlias> ->


<-! all incorporated pojo packet type mapping package configuration is simple names alias case-insensitive ->


<Package name = "cn.lijun.domain" />

</ typeAliases>

<-! configuration properties ->



- <Environments default = "Development">


- <environment id="development">

<transactionManager type="JDBC"/>


-<dataSource type="POOLED">

<Property name = "Driver" value = "$ {jdbc.driver}" />

<Property name = "URL" value = "$ {jdbc.url}" />

<Property name = "username" value = "$ { } jdbc.username "/>

<Property name =" password "value =" $ {jdbc.password} "/>

</ the dataSource>

</ Environment>

</ Environments>


- <by mappers>

<Resource Mapper =" CN / Lijun /dao/Userdao.xml "/>

<-! UserDao introduced interfaces must be configured before the introduction of the interface must match the same package file name ->


<-! <Mapper class =" cn.lijun.dao.UserDao "/> ->


<! - refer to all interfaces in a package dao ->


<package name =" cn.lijun.dao "/>

</ by mappers>

</ configuration>
Here is jdbc file
Resources need to be placed inside
= com.mysql.jdbc.Driver jdbc.driver 
jdbc.url = jdbc: MySQL: // localhost: 3306 / myb9502
jdbc.username = root
jdbc.password = root
This is a mapping file needs to be placed inside resources
<? xml Version = "1.0" encoding = "UTF-8"?> 
<DOCTYPE Mapper!
the PUBLIC "- // mybatis.org//DTD Mapper 3.0 // EN"
"http://mybatis.org/dtd/mybatis mapper.dtd--3 ">
<- dynamic proxy mode:! must comply with ->
<- namespace must be a corresponding interface permission class name ->!
<- Update the SELECT INSERT DELET four tag id attribute! the method must correspond to the value of the name of the interface ->
<Mapper namespace = "cn.lijun.dao.UserDao">
<SELECT ID = "the findAll" the resultType = "the USER">
SELECT * from User
</ SELECT>

<INSERT ID = " Save "the parameterType =" cn.lijun.domain.User ">
INSERT INTO User values (null," $ {username} ", pwd} {#, # Sex {}, # {address});
</insert>

</mapper>


Guess you like

Origin www.cnblogs.com/zhaowenyang/p/11313333.html