标签:ide use nbsp 点击 hid 配置 生成器 ngx png
【一】在要生成代码的项目模块的pom.xml文件中添加maven插件
<!--mybatis代码生成器--> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.2</version> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.34</version> </dependency> </dependencies> <configuration> <overwrite>true</overwrite> </configuration> </plugin>
【二】在要生成代码的项目模块的resources目录下添加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> <context id="mysqlgenerator" targetRuntime="MyBatis3"> <!--数据库连接信息--> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8" userId="root" password="shangxiaofei" /> <!--生成javaEntry实体--> <javaModelGenerator targetPackage="com.spring.test.entry.generator" targetProject="src/main/java" /> <!--生成mapper.xml--> <sqlMapGenerator targetPackage="mapper/custom" targetProject="src/main/resources" /> <!--生成的mapper的接口文件--> <javaClientGenerator type="XMLMAPPER" targetPackage="com.spring.test.mapper.generator" targetProject="src/main/java" /> <!--待生成的表名--> <table tableName="s_user"/> </context> </generatorConfiguration>
【三】在idea上配置启动命令。点击run-->Edit configurations-->maven选项->点击“+”号添加启动命令配置,如下图
【五】如果没有报错,在generatorConfig.xml配置的指定目录下则会生成相应的文件内如。如下图
【mybatis源码学习】利用maven插件自动生成mybatis代码
标签:ide use nbsp 点击 hid 配置 生成器 ngx png
原文地址:https://www.cnblogs.com/shangxiaofei/p/9460137.html