Mybatis基于XML配置SQL映射器(一)
Durid和Mybatis开发环境搭建
SpringBoot搭建基于Spring+SpringMvc+Mybatis的REST服务(http://www.cnblogs.com/nbfujx/p/7694768.html)
Mybatis之代码生成器
Maven Plugin管理
<build>
<plugins>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.5</version>
<executions>
<execution>
<id>Generate MyBatis Artifacts</id>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
generatorConfig.xml
配置相关内容
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE generatorConfiguration PUBLIC
"-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd" >
<generatorConfiguration> <!-- !!!! Driver Class Path !!!! -->
<classPathEntry location="C:\Users\Han\.m2\repository\mysql\mysql-connector-java\5.1.35\mysql-connector-java-5.1.35.jar"/> <context id="context" targetRuntime="MyBatis3">
<commentGenerator>
<property name="suppressAllComments" value="false"/>
<property name="suppressDate" value="true"/>
</commentGenerator> <!-- !!!! Database Configurations !!!! -->
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://10.1.51.235:3306/jawavesys" userId="root" password="jawave88"/> <javaTypeResolver>
<property name="forceBigDecimals" value="false"/>
</javaTypeResolver> <!-- !!!! Model Configurations !!!! -->
<javaModelGenerator targetPackage="com.goku.druid.demo.model" targetProject="src/main/java">
<property name="enableSubPackages" value="false"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator> <!-- !!!! Mapper XML Configurations !!!! -->
<sqlMapGenerator targetPackage="mapping" targetProject="src/main/resources">
<property name="enableSubPackages" value="false"/>
</sqlMapGenerator> <!-- !!!! Mapper Interface Configurations !!!! -->
<javaClientGenerator targetPackage="com.goku.druid.demo.mapper" targetProject="src/main/java" type="XMLMAPPER">
<property name="enableSubPackages" value="false"/>
</javaClientGenerator> <!-- !!!! Table Configurations !!!! -->
<table tableName="user_" domainObjectName="User" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false"
enableUpdateByExample="false"/>
</context>
</generatorConfiguration>
Maven生成语句配置(mybatis-generator:generate)

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

Mybatis之SpringBoot配置
mybatis-spring-boot-starter方式
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.0.0</version>
</dependency>
application.properties配置
# mybatis
mybatis.type-aliases-package=com.goku.mybatis.model
mybatis.mapper-locations=classpath:mapping/**/*.xml #pagehelper
pagehelper.helperDialect=mysql
pagehelper.reasonable=true
pagehelper.supportMethodsArguments=true
pagehelper.params=count=countSql
GITHUB
github : https://github.com/nbfujx/learn-java-demo/tree/master/Goku.MybatisDemo.XML
Mybatis基于XML配置SQL映射器(一)的更多相关文章
- Mybatis基于XML配置SQL映射器(二)
Mybatis之XML注解 之前已经讲到通过 mybatis-generator 生成mapper映射接口和相关的映射配置文件: 下面我们将详细的讲解具体内容 首先我们新建映射接口文档 sysUse ...
- Mybatis基于XML配置SQL映射器(三)
Mybatis之动态SQL mybatis 的动态sql语句是基于OGNL表达式的.可以方便的在 sql 语句中实现某些逻辑. 总体说来mybatis 动态SQL 语句主要有以下几类: if choo ...
- mybatis 基于xml 配置的映射器
cache 给命名空间的缓存配置 cache-ref 其他命名空间缓存配置的引用 resultMap 描述如何从数据库结果集中来加载对象 <!--column不做限制,可以为任意表的字段,而p ...
- Java Persistence with MyBatis 3(中文版) 第三章 使用XML配置SQL映射器
关系型数据库和SQL是经受时间考验和验证的数据存储机制.和其他的ORM 框架如Hibernate不同,MyBatis鼓励开发者可以直接使用数据库,而不是将其对开发者隐藏,因为这样可以充分发挥数据库服务 ...
- MyBatis学习笔记3--使用XML配置SQL映射器
<resultMap type="Student" id="StudentResult"> <id property="id&quo ...
- 小峰mybatis(5)mybatis使用注解配置sql映射器--动态sql
一.使用注解配置映射器 动态sql: 用的并不是很多,了解下: Student.java 实体bean: package com.cy.model; public class Student{ pri ...
- 小峰mybatis(4)mybatis使用注解配置sql映射器
主流开发还是使用xml来配置:使用注解配置比较快,但是不支持所有功能:有些功能还是得用配置文件: 一.基本映射语句: @Inert @Update @Delete @Select 二.结果集映射语句 ...
- (三)使用XML配置SQL映射器
SqlSessionFactoryUtil.java package com.javaxk.util; import java.io.IOException; import java.io.Input ...
- MyBatis 3 使用注解配置SQL映射器
l 在映射器Mapper接口上使用注解 l 映射语句 @Insert,@Update,@Delete,@SeelctStatements l 结果映射 一对一映射 一对多映射 l 动态SQL @Sel ...
随机推荐
- ssm框架错误展示-1
1.xmlParse错误+找不到bean ,一般会出现在导入别的地方拷来的项目时发生,报了以下错误: 查看自己的项目配置文件,发现spring的配置文件和sql映射xml文件都有个黄颜色的感叹号,鼠标 ...
- Hive数据如何同步到MaxCompute之实践讲解
摘要:本次分享主要介绍 Hive数据如何迁移到MaxCompute.MMA(MaxCompute Migration Assist)是一款MaxCompute数据迁移工具,本文将为大家介绍MMA工具的 ...
- bzoj4397【Usaco2015 Dec】Breed Counting(前缀和、树状数组)
题目描述 Farmer John's N cows, conveniently numbered 1…N, are all standing in a row (they seem to do so ...
- python练习题之全选框全不选反选
功能 实现分为两大部分: 第一body 部分,1,通过<li>无序列表标签实现选项的基本样式,通过input的checkbox标签实现里面的复选框功能.用到了标签的嵌套.然后选项的js方法 ...
- soj#547 bzoj5046 分糖果游戏
分析 代码 #include<bits/stdc++.h> using namespace std; #define int long long ; ][],s[],p[],v[]; si ...
- mysql 查询所有表以及对应的信息
https://www.cnblogs.com/ssslinppp/p/6178636.html use information_schema;selectengine,table_name,tabl ...
- 测开之路三十二:Flask基础之错误与重定向
错误处理,框架默认的错误为:not Found 可以捕获,并自定义 准备一张自定义图片,放在static文件夹下,并在template下创建一个html文件,引用该图片 捕获404状态,返回自定义页面 ...
- UIsearchBar 自定义样式
对于修改输入框圆角 的需求, 可以通过修改搜索框背景图片的方式设置. - (void)setSearchFieldBackgroundImage:(nullable UIImage *)backgro ...
- Php邮件发送源码
好久冒写点东西了.....最近生活压抑的很....为生活而劳累,整理下邮件发送的实例了,网上也有很多,我这个也是提取整理好的,测试Ok,首页邮件类smtp_email_class.php如下:< ...
- ASP.NET MVC4获取当前系统时间
<p>当前时间是:@ViewBag.CurrentDate.ToLongDateString()</p>