MyBatis自动生成工具

自动生成工具是一个为MyBatis提供接口生成的工具。可以自动导入MyBatis的映射信息。

引入自动生成工具

<dependency>
   <groupId>com.wueasy</groupId>
   <artifactId>wueasy-auto</artifactId>
   <version>RELEASE</version>
   <scope>test</scope>
</dependency>

数据库连接配置

修改数据库连接配置的信息

wueasy:
  auto:
    type: 2 #类型,1 通用mapper,2 原始方式,默认1
  datasource :
    demo :
      mybatis:
        basePackage: com.wueasy.auto.mapper
        mapperLocations: classpath*:mybatis/wueasy/auto/*.xml
      connection:
        url : jdbc:mysql://localhost:3306/easy_data?serverTimezone=UTC&useSSL=false&useUnicode=true&characterEncoding=utf-8
        username : easyadmin
        password : easyadmin
        #连接池配置
        initialSize : 10  #初始化大小
        minIdle : 10  #最小连接
        maxActive : 20  #最大连接
        maxWait : 60000  #配置获取连接等待超时的时间
        timeBetweenEvictionRunsMillis : 2000  #配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
        minEvictableIdleTimeMillis : 600000  #配置一个连接在池中最小生存的时间,单位是毫秒
        maxEvictableIdleTimeMillis : 600000  #配置一个连接在池中最大生存的时间,单位是毫秒
        validationQuery : SELECT 1 from dual
        testWhileIdle : true
        testOnBorrow : false
        testOnReturn : false
        keepAlive : true

执行类

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes=WueasyApplicationAuto.class)
public class ApplicationTests {

    @Autowired
    private AutoCodeService autoCodeService;

    /**
     * @author: fallsea
     */
    @Test
    public void testObj() {
        String tableName = "sys_log"; //表名称
        String entityPackage = "com.wueasy.admin.entity"; //实体包bean路径
        String mapperPackage = "com.wueasy.admin.mapper"; //mapper包路径
        String mapperXmlPackage = "mybatis.mapper.wueasy.sys"; //mapper配置文件包路径
        autoCodeService.auto(tableName, entityPackage, mapperPackage, mapperXmlPackage);
    }

}
Copyright © wueasy.com 2017-2019 all right reserved,powered by Gitbook未经允许,禁止以任何形式传播 修订时间: 2019-10-04

results matching ""

    No results matching ""