idea 使用 mybatis-generator
来源:互联网 发布:唐努乌梁海 知乎 编辑:程序博客网 时间:2024/05/16 03:31
系统环境:
jdk:1.7
idea:14
maven:3.1.1
第一步:创建maven项目(maven配置此处不说)
直接next
填写groupId和artifactId,然后next
finish。
第二步:编辑pom.xml
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.cc520</groupId> <artifactId>mybatis-generator</artifactId> <version>1.0-SNAPSHOT</version> <build> <finalName>520cc</finalName> <plugins> <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> </plugins> </build></project>
第三步:在src\main\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> <!--数据库的jdbc驱动jar包的位置 --> <classPathEntry location="D:/mysql-connector-java-5.1.30-bin.jar"/> <context id="default" targetRuntime="MyBatis3"> <!-- optional,旨在创建class时,对注释进行控制 --> <commentGenerator> <property name="suppressDate" value="true" /> </commentGenerator> <!--jdbc的数据库连接 --> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/ssm" userId="root" password="root"> </jdbcConnection> <javaModelGenerator targetPackage="com.c520l.domain" targetProject="src/main/java"> <!--构造函数 --> <property name="constructorBased" value="true"/> <!-- 是否允许子包,即targetPackage.schemaName.tableName --> <property name="enableSubPackages" value="false"/> <!-- 建立的对象是否有setter方法 false为有 true为没有 --> <property name="immutable" value="false"/> <!-- 对象的父类 --> <!--<property name="rootClass" value="com.c520l."/>--> <!-- 是否对类CHAR类型的列的数据进行trim操作 --> <property name="trimStrings" value="true"/> </javaModelGenerator> <!--Mapper映射文件生成所在的目录 --> <sqlMapGenerator targetPackage="com.c520l.mapping" targetProject="src/main/java"> <property name="enableSubPackages" value="false"/> </sqlMapGenerator> <javaClientGenerator targetPackage="com.c520l.dao" targetProject="src/main/java" type="MIXEDMAPPER"> <property name="enableSubPackages" value=""/> <property name="exampleMethodVisibility" value=""/> <property name="methodNameCalculator" value=""/> <property name="rootInterface" value=""/> </javaClientGenerator> <table schema="general" tableName="user" domainObjectName="user" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false" > <property name="useActualColumnNames" value="true"/> </table> </context></generatorConfiguration>第四部:配置运行
在command line中填写:
mybatis-generator:generate -e
ok,小功告成。
参考网络多篇博文整合而成。
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逆向工程生成代码
- 什么是阿里云数加大数据计算服务MaxCompute?
- js和php中if判断空数组的差异
- 解决公务车Bug:过路过桥费用管理中导入路桥费用时,付费方式为苏通卡时不能正常导入
- 浅谈TCP和UDP的区别
- node特性以及优缺点
- idea 使用 mybatis-generator
- C 和C++ 对定义结构体的区别
- laravel validator验证
- DDL、DML和DCL的区别与理解
- Android知识点之延迟加载:ViewStub的使用
- Android 去掉标题栏,状态栏,导航栏
- 5分钟学会使用DataHub接入实时数据到MaxCompute(原ODPS)
- iOS 自定义转场动画初探
- java 集合ArrayList及LinkList源码分析