Mybatis基于XML配置SQL映射器(一)
Durid和Mybatis开发环境搭建
SpringBoot搭建基于Spring+SpringMvc+Mybatis的REST服务(http://www.cnblogs.com/nbfujx/p/7694768.html)
Mybatis之代码生成器
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 的相关配置,然后启动生成
Mybatis之SpringBoot配置
mybatis-spring-boot-starter方式
1 <dependency> 2 <groupId>org.mybatis.spring.boot</groupId> 3 <artifactId>mybatis-spring-boot-starter</artifactId> 4 <version>1.0.0</version> 5 </dependency>
View Code
application.properties配置
1 # mybatis 2 mybatis.type-aliases-package=com.goku.mybatis.model 3 mybatis.mapper-locations=classpath:mapping/**/*.xml 4 5 #pagehelper 6 pagehelper.helperDialect=mysql 7 pagehelper.reasonable=true 8 pagehelper.supportMethodsArguments=true 9 pagehelper.params=count=countSql
View Code
GITHUB
github : https://github.com/nbfujx/learn-java-demo/tree/master/Goku.MybatisDemo.XML
转载于:https://www.cnblogs.com/nbfujx/p/7702571.html
Mybatis基于XML配置SQL映射器(一)相关推荐
- Mybatis基于XML配置SQL映射器(二)
Mybatis之XML注解 之前已经讲到通过 mybatis-generator 生成mapper映射接口和相关的映射配置文件: 下面我们将详细的讲解具体内容 首先我们新建映射接口文档 sysUse ...
- spring整合mybatis基于xml配置
数据库 /* Navicat MySQL Data Transfer Source Server : mysql Source Server Version : 50549 Sourc ...
- Maven使用注解配置SQL映射器(@Results,@ResultMap)
工程目录: 一.@Results映射 Client.java package client;import java.io.*; import java.util.List; import org.ap ...
- Maven使用注解配置SQL映射器(@Select,@Insert,@Update,@Delete)
工程目录: Client.java package client;import java.io.*; import java.util.List; import org.apache.ibatis.i ...
- mybatis入门配置——基于xml配置
1.下载mybatis配置文件,以及数据库驱动文件,最好配置日志文件log4j可以方便测试查看日志: mybatis配置文件以及log4j日志配置下载链接: http://download.csdn. ...
- ssm整合(基于xml配置方式)
本文是基于xml配置的方式来整合SpringMVC.Spring和Mybatis(基于注解的方式会再写一篇文章),步骤如下: (1)首先自然是依赖包的配置文件 pom.xml <project ...
- Mybatis-06【MyBatis基于XML的详细使用——缓存】
MyBatis基于XML的详细使用--缓存1.介绍2.一级缓存的使用3.二级缓存1. 缓存的使用2. 缓存的属性3. 二级缓存的作用范围4. 整合第三方缓存 1.介绍 MyBatis 内置了一个强大的 ...
- (Mybatis)XML配置解析
文章目录 XML配置解析 1.核心配置文件 2.环境配置(environments) 3. 属性(properties) 4. 设置(settings) 5. 其他配置 6. 映射器(mappers) ...
- 转载 - Struts2基于XML配置方式实现对action的所有方法进行输入校验
出处:http://www.cnblogs.com/Laupaul/archive/2012/03/15/2398360.html http://www.blogjava.net/focusJ/arc ...
最新文章
- 小白也能看懂的Matplotlib简明教程
- 了解JavaScript 对象的属性操作
- ML之FE:利用FE特征工程(分析两两数值型特征之间的相关性)对AllstateClaimsSeverity(Kaggle2016竞赛)数据集实现索赔成本值的回归预测
- 敏捷到底有没有带来新的东西?
- 嵌入式笔录(4)-LC并联电路选频和AM解调
- Exchange Server 2013日记功能
- layer加载的页面偶尔出现空白_Layer-Cake 模式的设计
- 智能化改造!AI技术在传统企业大有可为!
- .NET的委托和匿名函数应用一例
- css hsla和rgba的区别
- 为什么要使用boost::enable_shared_from_thisT
- 二重指针、二维数组及二者如何进行赋值
- 随机过程 - 马尔可夫链
- 【数据分析|面试】如何介绍你的项目经历
- 局域网联机_七日杀v17.2(B27)版/支持局域网联机/多项修改器/初始存档/局域网联机教程...
- 【信息学奥赛】1005:地球人口承载力估计(C++)
- HTTP/3 强势来袭?!
- linux读取excel并导入mysql_mysql命令行的导入导出sql,txt,excel(都在linux或windows命令行操作)(转自筑梦悠然)...
- 电脑连不上ishanghai_i-Shanghai免费上网将不限时 详解如何上网不掉线
- 电脑右击新建没有Word、Excel怎么办
热门文章
- CSS之background-position属性
- python 三维地球_用python生成地球运动的动态模拟动态图
- hdu 2196 computer
- 日志汇总:logging、logger
- 如何建立好的索引.--针对Distinct
- java orika_常见Bean映射工具分析评测及Orika介绍
- 5、Flutter 实现 ViewPager、bottomNavigationBar 界面切换
- android studio 导入依赖报错——Could not find com.xxx,(# fields: 66338 > 65536)
- Android 视频播放器,VideoView播放视频
- win7下搭建小程序服务器,技术开发人员告诉你微信小程序怎么做