总结一下java如何进行逆向工程
发布时间:2020-12-15 07:53:40 所属栏目:Java 来源:网络整理
导读:第一步 在百度搜索Mybatis generator 在官网进行搜索?http://www.mybatis.org/generator/?并且找到 ? ? ? 第二步 导入jar包点击See the? XML Configuration File Reference ?page for an example of a configuration file.建立xml文件根据提示修改代码 ?xml
第一步在百度搜索Mybatis generator 在官网进行搜索?http://www.mybatis.org/generator/?并且找到 ? ? ?第二步导入jar包点击See the?XML Configuration File Reference?page for an example of a configuration file.建立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> <!-- jar包位置 --> <classPathEntry location="D:jarmybatis-generator-core-1.3.5.jar" /> <!-- 数据源信息--> <context id="DB2Tables" targetRuntime="MyBatis3"> <!--禁止所有注释 --> <commentGenerator> <property name="suppressAllComments" value="true" /> </commentGenerator> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/mybatis" userId="root" password="root"> </jdbcConnection> <javaTypeResolver > <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <!-- 生产实体类的位置 --> <javaModelGenerator targetPackage="com.zhiyou100.xth.bean" targetProject="./src"> <property name="enableSubPackages" value="true" /> <property name="trimStrings" value="true" /> </javaModelGenerator> <!-- 生产映射文件所在位置 --> <sqlMapGenerator targetPackage="com.zhiyou100.xth.mapper" targetProject="./resources"> <property name="enableSubPackages" value="true" /> </sqlMapGenerator> <!-- 生产dao文件的所在位置 --> <javaClientGenerator type="XMLMAPPER" targetPackage="com.zhiyou100.xth.dao" targetProject="./src"> <property name="enableSubPackages" value="true" /> </javaClientGenerator> <!--表 schema 该表所在的数据库 domainObjectName 实体类名 --> <table schema="mybatis" tableName="users" domainObjectName="Users" enableCountByExample="false" enableDeleteByExample="false" enableSelectByExample="false" enableUpdateByExample="false" > <property name="useActualColumnNames" value="true"/> <generatedKey column="ID" sqlStatement="DB2" identity="true" /> <columnOverride column="DATE_FIELD" property="startDate" /> <ignoreColumn column="FRED" /> <columnOverride column="LONG_VARCHAR_FIELD" jdbcType="VARCHAR" /> </table> </context> </generatorConfiguration> ? ? 第三步运行 第四步 ?点击 ? 第五步? List<String> warnings = new ArrayList<String>(); boolean overwrite = true; File configFile = new File("generatorConfig.xml"); ConfigurationParser cp = new ConfigurationParser(warnings); Configuration config = cp.parseConfiguration(configFile); DefaultShellCallback callback = new DefaultShellCallback(overwrite); MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config,callback,warnings); myBatisGenerator.generate(null); 在主函数里面导包运行 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |