import java.io.File;
import java.util.ArrayList;
import java.util.List; import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.internal.DefaultShellCallback; public class AutoCreateBean {
public static void main(String[] args) {
String path = AutoCreateBean.class.getResource("").toString();
if (path != null)
{
path = path.substring(6,path.length());//如果是windwos将5变成6
if(path.indexOf("%e9%83%ad%e7%ab%af%e7%ab%af") !=-1){
path = path.replace("%e9%83%ad%e7%ab%af%e7%ab%af", "郭端端");
}
if(path.indexOf("%20")!=-1){
path = path.replaceAll("%20", " ") ; //本地包含空格的注意替换
}
System.out.println("current path :" + path);
}
try{
List<String> warnings = new ArrayList<String>();
boolean overwrite = true;
File configFile = new File(path+"generator.xml");//获取项目路径,在generator.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);
}catch(Exception e){
e.printStackTrace();
}
} }
<?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驱动的jar包地址-->
<classPathEntry location="D:/repository/mysql/mysql-connector-java/5.1.13/mysql-connector-java-5.1.13-bin.jar" />
<context id="openshopsqlSessionFactory" targetRuntime="MyBatis3"> <commentGenerator>
<property name="suppressDate" value="true" />
<property name="suppressAllComments" value="true"/>
</commentGenerator> <jdbcConnection driverClass="com.mysql.jdbc.Driver"
connectionURL="jdbc:mysql://10.19.105.184:3306/wms" userId="ggs"
password="ZPIOSVYLXMNI">
</jdbcConnection>
<!--数据库连接的信息:驱动类、连接地址、用户名、密码 -->
<!-- <jdbcConnection driverClass="oracle.jdbc.driver.OracleDriver" -->
<!-- connectionURL="jdbc:oracle:thin:@10.19.105.113:1521:orcl" userId="MWS" -->
<!-- password="MWS2015"> -->
<!-- </jdbcConnection> --> <javaTypeResolver>
<property name="forceBigDecimals" value="false" />
</javaTypeResolver>
<!-- targetProject:自动生成javaBean代码的位置 -->
<javaModelGenerator targetPackage="com.yunda.inter"
targetProject="D:/workspace/">
<property name="enableSubPackages" value="true" />
<!-- 从数据库返回的值被清理前后的空格 -->
<property name="trimStrings" value="true" />
</javaModelGenerator> <!-- xml文件 自动生成mapper.xml代码位置-->
<!-- enableSubPackages:是否让schema作为包的后缀 -->
<sqlMapGenerator targetPackage="com.yunda.inter"
targetProject="D:/workspace/">
<property name="enableSubPackages" value="true" />
</sqlMapGenerator> <!-- 自动生成mapper接口代码位置-->
<javaClientGenerator type="XMLMAPPER" targetPackage="com.yunda.inter"
targetProject="D:/workspace/">
<property name="enableSubPackages" value="true" />
</javaClientGenerator>
<!-- tableName:用于自动生成代码的数据库表;domainObjectName:对应于数据库表的javaBean类名 -->
<!--如果想要生成一个demo,则enableCountByExample设为true -->
<table tableName="riv_owner_tx_type" domainObjectName="RivOwnerTxType"
enableCountByExample="false"
enableUpdateByExample="false"
enableDeleteByExample="false"
enableSelectByExample="false"
selectByExampleQueryId="false" /> </context>
</generatorConfiguration>

mybatis-generator-core-1.3.2.jar

利用mybatis-generator生成po的更多相关文章

  1. 利用org.mybatis.generator生成实体类

    springboot+maven+mybatis+mysql 利用org.mybatis.generator生成实体类 1.添加pom依赖:   2.编写generatorConfig.xml文件 ( ...

  2. Mybatis分页-利用Mybatis Generator插件生成基于数据库方言的分页语句,统计记录总数 (转)

    众所周知,Mybatis本身没有提供基于数据库方言的分页功能,而是基于JDBC的游标分页,很容易出现性能问题.网上有很多分页的解决方案,不外乎是基于Mybatis本机的插件机制,通过拦截Sql做分页. ...

  3. Mybatis逆向工程生成po、mapper接口、mapper.xml

    Mybatis逆向工程生成po.mapper接口.mapper.xml 一.新建一个maven工程 请查看我的另一篇博客:<使用idea创建一个maven工程> 二.引入所需依赖 需要my ...

  4. MyBatis Generator 生成的example 使用 and or 简单混合查询

    MyBatis Generator 生成的example 使用 and or 简单混合查询 参考博客:https://www.cnblogs.com/kangping/p/6001519.html 简 ...

  5. mybatis Generator生成代码及使用方式

    本文原创,转载请注明:http://www.cnblogs.com/fengzheng/p/5889312.html 为什么要有mybatis mybatis 是一个 Java 的 ORM 框架,OR ...

  6. Maven下用MyBatis Generator生成文件

    使用Maven命令用MyBatis Generator生成MyBatis的文件步骤如下: 1.在mop文件内添加plugin <build> <finalName>KenShr ...

  7. MyBatis Generator生成DAO——序列化

    MyBatis Generator生成DAO 的时候,生成的类都是没有序列化的. 还以为要手工加入(開始是手工加入的),今天遇到分页的问题,才发现生成的时候能够加入插件. 既然分页能够有插件.序列化是 ...

  8. 【记录】Mybatis Generator生成数据对象Date/TimeStamp 查询时间格式化

    Mybatis Generator是很好的工具帮助我们生成表映射关联代码,最近博主遇到一个问题,找了很久才解决, 就是用Mybatis Generator生成实体类的时候,Date 时间无法格式化输出 ...

  9. 利用mybatis generator实现数据库之间的表同步

    项目背景: 项目需要对两个服务器上的表进行同步,表的结构可能不一样.比如服务器A上的表i同步数据到服务器B上的表j,i和j的结构可能不一样,当然大部分字段是一样的.项目看起来很简单,网上一搜也是很多, ...

  10. Mybatis Generator生成工具配置文件详解

    <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration ...

随机推荐

  1. 求解范围中 gcd(a,b)== prime 的有序对数

    题目: 给定整数N,求1<=x,y<=N且Gcd(x,y)为素数的数对(x,y)有多少对. 输入: 一个整数N. 输出: 如题. Sample  Input 4 Sample Output ...

  2. AtCoder Grand Contest 014 题解

    A - Cookie Exchanges 模拟 Problem Statement Takahashi, Aoki and Snuke love cookies. They have A, B and ...

  3. 【转】LCS

    动态规划法 经常会遇到复杂问题不能简单地分解成几个子问题,而会分解出一系列的子问题.简单地采用把大问题分解成子问题,并综合子问题的解导出大问题的解的方法,问题求解耗时会按问题规模呈幂级数增加. 为了节 ...

  4. VIJOS:P1706(舞会)

    描述 Arthur公司是一个等级森严的公司,它们有着严格的上司与下属的关系,公司以总裁为最高职位,他有若干个下属,他的下属又有若干个下属,他的下属的下属又有若干个下属……现接近年尾,公司组织团拜活动, ...

  5. CUDA V9.2 sample编译问题

    这个哥们也遇到一样的问题 CUDA 9.1/9.2 与 Visual Studio 2017 (VS2017 15.6.4) 的不兼容问题 错误有显示 #if _MSC_VER < 1600 | ...

  6. k8s 基础 pod创建流程

    Pod是Kubernetes中最基本的部署调度单元,可以包含container,逻辑上表示某种应用的一个实例.例如一个web站点应用由前端.后端及数据库构建而成,这三个组件将运行在各自的容器中,那么我 ...

  7. linux日常管理-查看系统负载

    查看系统的负载常用命令w 16:32::15是系统时间 up 16 min 是开机使用时间 1 user 是登录的用户数 重要 load average:0.00 0.00 0.00 负载分别表示1分 ...

  8. javaScript之this的五种情况

    this一直是JavaScript研究的难题,特别是在笔试和面试中的各种程序分析问题中,也常常会被问到.下面来看一看this被运用的五中情况: (1)       纯粹的函数调用 函数最普通用法,此时 ...

  9. angularJS中自定义指令

    学习了angularJS一周,但是大部分时间被自定义指令占用了.博主表示自学互联网好心塞的,发现问题的视觉很狭窄,这比解决问题要更难.这篇文章首先介绍了自定义,然后介绍了在使用自定义指令遇到的问题. ...

  10. JavaScript高级程序设计学习笔记第十五章--使用Canvas绘图

    一.基本用法 1.要使用<canvas>元素,必须先设置其 width 和 height 属性,指定可以绘图的区域大小.能通过 CSS 为该元素添加样式,如果不添加任何样式或者不绘制任何图 ...