日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > asp.net >内容正文

asp.net

Mybatis基于XML配置SQL映射器(一)

發布時間:2023/12/10 asp.net 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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映射器(一)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。