eclipse安装插件,new,新建一个Mybatis Generator Configuration File
文件内容:
<?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="F:/NJmrk/mysql-connector-java-5.1.41.jar"/> <context id="mysql_table" targetRuntime="MyBatis3"> <commentGenerator> <property name="suppressDate" value="true" /> <!-- 是否去除自动生成的注释 true:是 : false:否 --> <property name="suppressAllComments" value="true" /> </commentGenerator> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/demo" userId="root" password="123456"> </jdbcConnection> <javaTypeResolver> <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <javaModelGenerator targetPackage="com.xi.entity" targetProject="zhibing_mybatis/src/main/java"> <property name="enableSubPackages" value="true" /> <property name="trimStrings" value="true" /> </javaModelGenerator> <!-- 生成映射文件的包名和位置 --> <sqlMapGenerator targetPackage="com.xi.mapping" targetProject="zhibing_mybatis/src/main/java"> <property name="enableSubPackages" value="true" /> </sqlMapGenerator> <!-- 生成DAO的包名和位置 --> <javaClientGenerator type="XMLMAPPER" targetPackage="com.xi.dao" targetProject="zhibing_mybatis/src/main/java"> <property name="enableSubPackages" value="true" /> </javaClientGenerator> <!-- 要生成的实体和对应的来源表 --> <table tableName="mdept" domainObjectName="Dept" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false"> <property name="useActualColumnNames" value="true" /> </table> <!-- <table schema="???" tableName="???"> <columnOverride column="???" property="???" /> </table> --> </context> </generatorConfiguration>
配置文件中,包名,开始的时候是:generator.dao,generator.entity,generator.mapping----------无法完成自动生成代码,后改为文件中名称后,可正常生成代码,
具体原因不详。
时间: 2024-10-13 01:52:13