mybatis generator 配置 反向生成Entity简单增删改查(推荐)
更新时间:2016年12月07日 11:00:41 作者:yhtgb
这篇文章主要介绍了mybatis generator 配置 反向生成Entity简单增删改查(推荐)的相关资料,非常不错,具有参考借鉴价值,需要的朋友可以参考下
mybatis generator 配置 反向生成Entity简单增删改查实例代码如下所示:
<?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> <!--数据库驱动jar --> <classPathEntry location="D:\.m2\repository\mysql\mysql-connector-java\5.1.38\mysql-connector-java-5.1.38.jar" /> <context id="DB2Tables" targetRuntime="MyBatis3"> <!--去除注释 --> <commentGenerator> <property name="suppressAllComments" value="true" /> </commentGenerator> <!--数据库连接 --> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://192.168.5.159:3306/数据库名称" userId="用户名" password="你懂得"> </jdbcConnection> <!--默认false Java type resolver will always use java.math.BigDecimal if the database column is of type DECIMAL or NUMERIC. --> <javaTypeResolver> <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <!--生成实体类 指定包名 以及生成的地址 (可以自定义地址,但是路径不存在不会自动创建 使用Maven生成在target目录下,会自动创建) --> <javaModelGenerator targetPackage="com.heaboy.包名.base.entity" targetProject="项目名"> <property name="enableSubPackages" value="false" /> <property name="trimStrings" value="true" /> </javaModelGenerator> <!--生成SQLMAP文件 --> <sqlMapGenerator targetPackage="com.heaboy.包名.mybatis" targetProject="项目名"> <property name="enableSubPackages" value="false" /> </sqlMapGenerator> <!--生成Dao文件 可以配置 type="XMLMAPPER"生成xml的dao实现 context id="DB2Tables" 修改targetRuntime="MyBatis3" --> <javaClientGenerator type="XMLMAPPER" targetPackage="com.heaboy.包名.base.dao" targetProject="项目名"> <property name="enableSubPackages" value="false" /> </javaClientGenerator> <!--对应数据库表 mysql可以加入主键自增 字段命名 忽略某字段等 --> <table tableName="表名" domainObjectName="生成的实体名" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" delimitIdentifiers="true"> <property name="useActualColumnNames" value="true" /> </table> <table tableName="表名2" domainObjectName="生成的实体名2" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <property name="useActualColumnNames" value="true" /> </table> </context> </generatorConfiguration>
以上所述是小编给大家介绍的mybatis generator 配置 反向生成Entity简单增删改查,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!
相关文章
项目连接nacos配置中心报错:Client not connected, current
这篇文章主要介绍了项目连接nacos配置中心报错:Client not connected, current status:STARTING的解决方案,采用了mysql作为持久化的数据库,docker作为运行的环境,感兴趣的朋友跟随小编一起看看吧2024-03-03
SpringCloud负载均衡spring-cloud-starter-loadbalancer解读
这篇文章主要介绍了SpringCloud负载均衡spring-cloud-starter-loadbalancer使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教2025-03-03
java中long(Long)与int(Integer)之间的转换方式
这篇文章主要介绍了java中long(Long)与int(Integer)之间的转换方式,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2020-10-10


最新评论