码迷,mamicode.com
首页 > 其他好文 > 详细

Mybatis基于XML定义开发

时间:2017-10-21 12:58:18      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:log   odi   main   plugin   group   span   target   inter   let   

 Durid和Mybatis开发环境搭建

Druid数据源配置入门(http://www.cnblogs.com/nbfujx/p/7686634.html
Druid动态数据源配置(http://www.cnblogs.com/nbfujx/p/7687788.html

Mybatis-Generator代码生成器

Maven Plugin管理

技术分享
 1  <build>
 2         <plugins>
 3             <plugin>
 4                 <groupId>org.mybatis.generator</groupId>
 5                 <artifactId>mybatis-generator-maven-plugin</artifactId>
 6                 <version>1.3.5</version>
 7                 <executions>
 8                     <execution>
 9                         <id>Generate MyBatis Artifacts</id>
10                         <goals>
11                             <goal>generate</goal>
12                         </goals>
13                     </execution>
14                 </executions>
15             </plugin>
16             <plugin>
17                 <groupId>org.apache.maven.plugins</groupId>
18                 <artifactId>maven-compiler-plugin</artifactId>
19                 <configuration>
20                     <source>1.6</source>
21                     <target>1.6</target>
22                 </configuration>
23             </plugin>
24         </plugins>
25     </build>
View Code

generatorConfig.xml

配置相关内容

技术分享
 1 <?xml version="1.0" encoding="UTF-8" ?>
 2 <!DOCTYPE generatorConfiguration PUBLIC
 3         "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
 4         "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
 5 <generatorConfiguration>
 6 
 7     <!-- !!!! Driver Class Path !!!! -->
 8     <classPathEntry location="C:\Users\Han\.m2\repository\mysql\mysql-connector-java\5.1.35\mysql-connector-java-5.1.35.jar"/>
 9 
10     <context id="context" targetRuntime="MyBatis3">
11         <commentGenerator>
12             <property name="suppressAllComments" value="false"/>
13             <property name="suppressDate" value="true"/>
14         </commentGenerator>
15 
16         <!-- !!!! Database Configurations !!!! -->
17         <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://10.1.51.235:3306/jawavesys" userId="root" password="jawave88"/>
18 
19         <javaTypeResolver>
20             <property name="forceBigDecimals" value="false"/>
21         </javaTypeResolver>
22 
23         <!-- !!!! Model Configurations !!!! -->
24         <javaModelGenerator targetPackage="com.goku.druid.demo.model" targetProject="src/main/java">
25             <property name="enableSubPackages" value="false"/>
26             <property name="trimStrings" value="true"/>
27         </javaModelGenerator>
28 
29         <!-- !!!! Mapper XML Configurations !!!! -->
30         <sqlMapGenerator targetPackage="mapping" targetProject="src/main/resources">
31             <property name="enableSubPackages" value="false"/>
32         </sqlMapGenerator>
33 
34         <!-- !!!! Mapper Interface Configurations !!!! -->
35         <javaClientGenerator targetPackage="com.goku.druid.demo.mapper" targetProject="src/main/java" type="XMLMAPPER">
36             <property name="enableSubPackages" value="false"/>
37         </javaClientGenerator>
38 
39         <!-- !!!! Table Configurations !!!! -->
40         <table tableName="user_" domainObjectName="User" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
41                enableUpdateByExample="false"/>
42     </context>
43 </generatorConfiguration>
View Code

Maven生成语句配置(mybatis-generator:generate

技术分享

Maven生成语句启动

修改 generatorConfig.xml 里 Table Configurations 的相关配置,然后启动生成

技术分享

Mapper.xml映射文件讲解

 待续

 

GITHUB

github :  https://github.com/nbfujx/learn-java-demo/tree/master/Goku.MybatisDemo.XML

Mybatis基于XML定义开发

标签:log   odi   main   plugin   group   span   target   inter   let   

原文地址:http://www.cnblogs.com/nbfujx/p/7702571.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!