Mybatis插件自动生成mapper.xml和dao
博客专区 > Curry_M 的博客 > 博客详情
Mybatis插件自动生成mapper.xml和dao
Curry_M 发表于8个月前
Mybatis插件自动生成mapper.xml和dao
  • 发表于 8个月前
  • 阅读 23
  • 收藏 0
  • 点赞 0
  • 评论 0

腾讯云 十分钟定制你的第一个小程序>>>   

1.pom文件中导入插件jar包

<plugin>
					<groupId>org.mybatis.generator</groupId>
					<artifactId>mybatis-generator-maven-plugin</artifactId>
					<version>1.3.2</version>
					<configuration>
						<verbose>true</verbose>
						<overwrite>true</overwrite>
					</configuration>
				</plugin>

2.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>
    <classPathEntry location="E:/mysql-connector-java-5.1.25.jar" />
    <context id="DB2Tables" targetRuntime="MyBatis3">
      <commentGenerator>
        <property name="suppressAllComments" value="true"/>
      </commentGenerator>
      <jdbcConnection driverClass="com.mysql.jdbc.Driver"
            connectionURL="jdbc:mysql://10.20.22.211:3306/roadassistant"
            userId="root" password="mysql123">
        </jdbcConnection>
      <javaTypeResolver>
         <property name="forceBigDecimals" value="false"/>
      </javaTypeResolver>
      
      <javaModelGenerator targetPackage="com.pingan.insurance.roadassistant.model" 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.pingan.insurance.roadassistant.dao" targetProject="src/main/java">
        <property name="enableSubPackages" value="true"/>
      </javaClientGenerator>
      <table  tableName="rule_condition" domainObjectName="RuleCondition" enableCountByExample="false" enableSelectByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"/>
      <table  tableName="rule_condition_extra" domainObjectName="RuleConditionExtra" enableCountByExample="false" enableSelectByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"/>
      <table  tableName="rule_instance" domainObjectName="RuleInstance" enableCountByExample="false" enableSelectByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"/>
      <table  tableName="rule_operator" domainObjectName="RuleOperator" enableCountByExample="false" enableSelectByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"/>
      <table  tableName="rule_property" domainObjectName="RuleProperty" enableCountByExample="false" enableSelectByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"/>
      <table  tableName="rule_result" domainObjectName="RuleResult" enableCountByExample="false" enableSelectByExample="false" enableUpdateByExample="false" enableDeleteByExample="false"/>
    </context>
      
</generatorConfiguration>

在generatorConfig.xml上右击:Run As-->Run Configurations-->点击项目--->mybatis-generator:generate

 

共有 人打赏支持
粉丝 2
博文 38
码字总数 38900
×
Curry_M
如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
* 金额(元)
¥1 ¥5 ¥10 ¥20 其他金额
打赏人
留言
* 支付类型
微信扫码支付
打赏金额:
已支付成功
打赏金额: