mybatis-generator:generate
<?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:\maven\soft-maven\com\oracle\ojdbc6\11.1.0.7.0\ojdbc6-11.1.0.7.0.jar"/>
<!-- TDS 2018.5.18关于自动生成mapper文件配置 总结
1,数据库为oracle 2, 要数据库建了有了表才能生成mapper
3,在pom文件最后配置<build>.4项目run as Maven build
(mybatis-generator:generate maven命令) 运行成功便生成了对应得mapper文件
下面附上build 配置-->
<!--
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-maven-plugin</artifactId>
<version>1.3.2</version>
<configuration>
<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
<overwrite>true</overwrite>
<verbose>true</verbose>
</configuration>
</plugin>
</plugins>
</build>-->
<context id="context1">
<commentGenerator>
<property name="suppressAllComments" value="true" />
</commentGenerator>
<jdbcConnection connectionURL="jdbc:oracle:thin:@//172.20.19.205:1521/epay"
driverClass="oracle.jdbc.driver.OracleDriver" password="自己的数据库密码" userId="ecard" />
<!-- 实体类生成的位置 -->
<javaModelGenerator targetPackage="com.epcc.model" targetProject="E:\STS\epcc\src\main\java\com\epcc\dao\BsecontractOrderMapper1.java" >
<property name="enableSubPackages" value="false"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<!-- *Mapper.xml 文件的位置 -->
<sqlMapGenerator targetPackage="com.epcc.dao" targetProject="E:\STS\epcc\src\main\resources\" >
<property name="enableSubPackages" value="false"/>
</sqlMapGenerator>
<!-- Mapper 接口文件的位置 -->
<javaClientGenerator targetPackage="com.efps.epcc.dao" targetProject="E:\STS\epcc\src\main\java\com\epcc\dao\BsecontractOrder\" type="XMLMAPPER" >
<property name="enableSubPackages" value="false"/>
</javaClientGenerator>
<!--自动生成mapper ,前面是表名,后面是生成的类名 -->
<table tableName="EPCC_BSECONTRACT_ORDER" domainObjectName="BsecontractOrder2"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
<!--自动生成mapper ,前面是表名,后面是生成的类名 其他表-->
<!-- <table tableName="EPCC_SIGNCONTRACT_INFO" domainObjectName="SignContractInfo"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
<table tableName="EPCC_AGREEMENTPAY_ORDER" domainObjectName="AgreementPayOrder"
enableCountByExample="false" enableUpdateByExample="false"
enableDeleteByExample="false" enableSelectByExample="false"
selectByExampleQueryId="false">
</table>
</context>
</generatorConfiguration>
===============================================================================================
二,关于方法配置参数问题
Dao里的方法字段与mapper.xml里的字段一样即可
1.在springboot中 一对于mapper文件结构一定要对应,xml的位置要在相同结构的包下.不然会报无效引用,如图
2.对于maven生成的mapper,如果你生成了2次或以上,很可能sql会生成两份在同一个mapper中,导致无法运行.下面这个是正常的.
最后总结:遇到程序报错,一定要冷静,有错,一定是自己那些地方没写正确,或者问题没找到.不要怀疑代码,更不要怀疑自己!