首页 > 其他分享 >maven 自动生成mybatis代码

maven 自动生成mybatis代码

时间:2023-02-19 23:37:40浏览次数:31  
标签:enableUpdateByExample enableSelectByExample 代码 maven mybatis enableCountByExampl


<!-- dependency和plugin中jar的版本根据自己需求选择,但同一个jar版本要保持一致 -->
<!-- 配置在dependencies中 -->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>1.3.7</version>
</dependency>
<!-- 在build中,注意,不要写在pluginManagement中,另起一段,单独写plugins -->
<plugins>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.7</version>
<dependencies>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>19.16.0.0</version>
</dependency>
</dependencies>
<configuration>
<overwrite>true</overwrite>
<!--<configurationFile>./generatorConfig.xml</configurationFile>-->
</configuration>
</plugin>
</plugins>

maven 自动生成mybatis代码_java

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>

<!--

<!-- mysql-connector-java 版本需要与pom中引得版本一致 -->
<classPathEntry location="C:\enviorment\repository\com\oracle\database\jdbc\ojdbc8\19.16.0.0\ojdbc8-19.16.0.0.jar" />

<context id="oracle2Tables" targetRuntime="MyBatis3">

<!-- 不加注释,因为默认注释是英文的 -->
<commentGenerator>
<property name="addRemarkComments" value="true"/>
<property name="suppressDate" value="true"/>
</commentGenerator>

<!-- 数据库连接信息 -->
<jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver"
connectionURL="jdbc:oracle:thin:@es111:1521:orcl"
userId="fsxt_1"
password="123456">
</jdbcConnection>

<javaTypeResolver >
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>


<!-- targetPackage 文件生成在指定包下,targetProject 路径-->
<javaModelGenerator targetPackage="com.cz.mhm.entity" targetProject="src/main/java">
<property name="enableSubPackages" value="true" />
<property name="trimStrings" value="true" />
</javaModelGenerator>

<sqlMapGenerator targetPackage="mapper" targetProject="src/main/resources">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator>

<javaClientGenerator type="XMLMAPPER" targetPackage="com.cz.mhm.dao" targetProject="src/main/java">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>

<!-- 数据库表以及对应的java模型类名(如果是多个表的话,可以复制多份然后修改成对应的表以及需要生成的模型名) -->
<!-- 入模指标-申请额-季度和月度 -->
<!--
<table tableName="DM_RMZB_SQ_JIDU" domainObjectName="ShenqingJidu"
enableCountByExample="false" enableUpdateByExample="true"
enableDeleteByExample="true" enableSelectByExample="true"
selectByExampleQueryId="true">
</table>

<table tableName="DM_RMZB_SQ_YUEDU" domainObjectName="ShenqingYuedu"
enableCountByExample="false" enableUpdateByExample="true"
enableDeleteByExample="true" enableSelectByExample="true"
selectByExampleQueryId="true">
</table>
-->

<!-- 入模指标 归集额-季度和月度 -->
<!--
<table tableName="DM_RMZB_GJ_JIDU" domainObjectName="GuijiJidu"
enableCountByExample="false" enableUpdateByExample="true"
enableDeleteByExample="true" enableSelectByExample="true"
selectByExampleQueryId="true">
</table>

<table tableName="DM_RMZB_GJ_YueDU" domainObjectName="GuijiYuedu"
enableCountByExample="false" enableUpdateByExample="true"
enableDeleteByExample="true" enableSelectByExample="true"
selectByExampleQueryId="true">
</table>
-->

<!-- 入模指标 回收额-季度和月度 -->
<!--
<table tableName="DM_RMZB_HS_JIDU" domainObjectName="HuishouJidu"
enableCountByExample="false" enableUpdateByExample="true"
enableDeleteByExample="true" enableSelectByExample="true"
selectByExampleQueryId="true">
</table>

<table tableName="DM_RMZB_HS_YUEDU" domainObjectName="HuishouYuedu"
enableCountByExample="false" enableUpdateByExample="true"
enableDeleteByExample="true" enableSelectByExample="true"
selectByExampleQueryId="true">
</table>
-->

<!-- 入模指标 提取额-季度和月度 -->
<table tableName="DM_RMZB_TQ_JIDU" domainObjectName="TiquJidu"
enableCountByExample="false" enableUpdateByExample="true"
enableDeleteByExample="true" enableSelectByExample="true"
selectByExampleQueryId="true">
</table>

<table tableName="DM_RMZB_TQ_YUEDU" domainObjectName="TiquYuedu"
enableCountByExample="false" enableUpdateByExample="true"
enableDeleteByExample="true" enableSelectByExample="true"
selectByExampleQueryId="true">
</table>

</context>
</generatorConfiguration>

 

执行

maven 自动生成mybatis代码_mybatis_02

 

标签:enableUpdateByExample,enableSelectByExample,代码,maven,mybatis,enableCountByExampl
From: https://blog.51cto.com/u_21817/6066943

相关文章

  • maven+本地jar后,普通项目打包
    项目中用到本地jar和maven,java-jar提示没有主清单1、项目中依赖本地包<dependency><groupId>aspose-words</groupId><artifactId>aspose-words-jdk16</artifa......
  • 通过代码,解释ExecutorService基本用法
     packagetest1;importjava.util.concurrent.ExecutorService;importjava.util.concurrent.Executors;/***通过以下代码可看出,线程池0-2用完后,释放,再放入3-5,如此循环,直......
  • 简单多线程卖票代码
     publicclassThread2{publicstaticvoidmain(String[]args){ShareDatad=newShareData();//两个窗口卖票newThread(d).start();newThread(d).st......
  • 通过代码,了解ThreadLocal
    在看此代码时,先看​​http://www.iteye.com/topic/103804​​ 如果ThreadLocal.set()进去的东西本来就是多个线程共享的同一个对象,那么多个线程的ThreadLocal.get()取得的......
  • 由于找不到msvcr110.dll,无法继续执行代码怎么办?
    msvcr110.dll丢失怎么修复?msvcr110.dll是一个电脑系统相当重要的文件,是属于电脑系统运行的默认文件之一,缺少这个文件,电脑上的程序运行就没有办法正常进行,会出现强行中断,电脑......
  • 重学c语言(纯代码)
    //复习自写/*intmain(){//计算1-100中有多少个9 inti=0; intcount=0; for(i=1;i<=100;i++) { if(i%10==9) {  printf("%d",i);  ......
  • 代码随想录算法训练营第三十五天 | 435. 无重叠区间,763.划分字母区间,56. 合并区间
    一、参考资料无重叠区间https://programmercarl.com/0435.%E6%97%A0%E9%87%8D%E5%8F%A0%E5%8C%BA%E9%97%B4.html划分字母区间https://programmercarl.com/0763.%E......
  • mybatis操作数据库
    mybatis介绍mybatis不会对应用程序或者数据库的现有设计强加任何影响。sql写在xml里,便于统一管理和优化。通过sql语句可以满足操作数据库的所有需求。mybatis结构操......
  • 10.MyBatis-Plus的使用
    整合MyBatis-Plus导入依赖在解决逆向工程生成的代码报错时候已经给bianen-common导入了依赖导入数据库的驱动导入驱动和MySql的版本有关,我安装的MySql版本是5.7.36打......
  • 完整代码文件
    环境配置代码1#安装库2!pipinstallnumpypandasmatplotlibrequeststqdmopencv-pythonpillowgc-ihttps://pypi.tuna.tsinghua.edu.cn/simple3#下载安......