IDEA使用mybatis-generator
来源:互联网 发布:163 imap 端口 编辑:程序博客网 时间:2024/05/23 12:34
1,使用需要导入的包,以及插件
<dependency> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-core</artifactId> <version>1.3.2</version> <scope>test</scope> </dependency><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,xml的命名不能随便取,必须是generatorConfig.xml,不然会报错的!
3,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:数据库的JDBC驱动 --> <classPathEntry location="D:\WorkPlace\MvnRepo\mysql\mysql-connector-java\5.1.34\mysql-connector-java-5.1.34.jar" /> <context id="MysqlTables" targetRuntime="MyBatis3"> <!-- 注意这里面的顺序确定的,不能随变更改 --> <!-- 自定义的分页插件 <plugin type="com.deppon.foss.module.helloworld.shared.PaginationPlugin"/> --> <!-- 可选的(0 or 1) --> <!-- 注释生成器 --> <commentGenerator> <!-- 是否去除自动生成的注释 true:是 : false:否 --> <property name="suppressAllComments" value="true" /> </commentGenerator> <!-- 必须的(1 required) --> <!--数据库连接的信息:驱动类、连接地址、用户名、密码 --> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/mvn-demo" userId="root" password="123456"> </jdbcConnection> <!-- 可选的(0 or 1) --> <!-- 类型转换器或者加类型解析器 --> <!-- 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer true,把JDBC DECIMAL 和 NUMERIC 类型解析为java.math.BigDecimal --> <javaTypeResolver> <property name="forceBigDecimals" value="false" /> </javaTypeResolver> <!-- 必须的(1 required) --> <!-- java模型生成器 --> <!-- targetProject:自动生成代码的位置 --> <javaModelGenerator targetPackage="top.aiprogram.student.entity" targetProject="D:\WorkPlace\ideaProjects\mvn-demo\src\main\java" > <!-- TODO enableSubPackages:是否让schema作为包的后缀 --> <property name="enableSubPackages" value="true" /> <!-- 从数据库返回的值被清理前后的空格 --> <property name="trimStrings" value="true" /> </javaModelGenerator> <!-- 必须的(1 required) --> <!-- map xml 生成器 --> <sqlMapGenerator targetPackage="top.aiprogram.student.mapper" targetProject="D:\WorkPlace\ideaProjects\mvn-demo\src\main\java"> <property name="enableSubPackages" value="true" /> </sqlMapGenerator> <!-- 可选的(0 or 1) --> <!-- mapper 或者就是dao接口生成器 --> <javaClientGenerator targetPackage="top.aiprogram.student.dao" targetProject="D:\WorkPlace\ideaProjects\mvn-demo\src\main\java" type="XMLMAPPER"> <property name="enableSubPackages" value="true" /> </javaClientGenerator> <!-- 必须的(1...N) --> <!-- pojo 实体生成器 --> <!-- tableName:用于自动生成代码的数据库表;domainObjectName:对应于数据库表的javaBean类名 --> <!-- schema即为数据库名 可不写 --> <table tableName="student" domainObjectName="Student" enableInsert="true" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"> <!-- 忽略字段 可选的(0 or 1) --> <!-- <ignoreColumn column="is_use" /> --> <!--//无论字段是什么类型,生成的类属性都是varchar。 可选的(0 or 1) 测试无效 --> <!-- <columnOverride column="city_code" jdbcType="VARCHAR" /> --> </table> </context></generatorConfiguration>4,最后就完成了啦!
阅读全文
0 0
- idea 使用 mybatis-generator
- IDEA使用mybatis-generator
- IDEA中使用MyBatis Generator快速开发
- idea + mybatis generator + maven 插件使用
- idea mybatis generator
- mybatis-generator IDEA 使用方法
- idea mybatis generator
- Intellij IDEA中使用MyBatis-generator 自动生成MyBatis代码
- IDEA下Maven项目中使用Mybatis及Mybatis Generator
- Intellij IDEA中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 中使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 中使用 MyBatis-generator 自动生成 MyBatis 代码
- idea 使用MyBatis-generator 自动生成MyBatis代码
- Intellij IDEA 中使用 MyBatis-generator 自动生成 MyBatis 代码
- Intellij IDEA 中使用 MyBatis-generator 自动生成 MyBatis 代码
- Intellij IDEA中使用MyBatis-generator 自动生成MyBatis代码
- IntelliJ Idea使用笔记(一):使用mybatis generator插件
- 在IDEA中使用MyBatis Generator逆向工程生成代码
- 走进大数据开源项目
- 十进制装换为二进制至九进制之间的任意进制输出
- spring AspectJ的Execution表达式
- 配置了系统环境变量不起作用
- Thoughtworks——出租车
- IDEA使用mybatis-generator
- Square HDU
- hdu3333 (线段树+离散化+离线处理)
- 画一个五角星
- SQL数据库开发基础
- 在OC项目下实现SwiftMonkey
- extends作业一
- Spring Boot 配置静态资源处理
- 在Jenkins下集成SwiftMonkey