springboot微服务快速构建利器springboot-dagger-x

springboot-dagger-x修复springboot-dagger多个bug,并重整构建项目结构,更加专一的构建springboot微服务工程

1.IDEA构建一个普通的maven项目(参考 springboot-dagger介绍-如何构建maven工程)

2.maven的pom文件中添加如下依赖


  com.github.LQliuqiang
  springboot-dagger-x
  1.4.RELEASE


  mysql
  mysql-connector-java
  5.1.49

3.springboot-dagger-x 1.2版本的使用

 1)使用方法介绍

public class Main {

    public static void main(String[] args) throws Exception {
        //数据库链接信息配置
        JdbcConfigEntity jdbcConfigEntity = new JdbcConfigEntity.Builder("mysql用户名", "mysql密码", "数据库名称")
                .url("mysql链接地址", 3306)
                .build();
        //springboot脚手架使用
        SpringBootCli springBootCli = new SpringBootCli.Builder(Main.class, jdbcConfigEntity)
                .useRedis(true) //是否使用redis,默认否
                .setFilterTableNameStr("tbl_") //去除数据库的表名称中的字符,如表名称tbl_user去除tbl_字符串后变成user
                .setUsePage(true) //是否使用分页
                .generateController(true) //是否生成controller,默认否
                .setForceCover(true) //***是否强制重新覆盖生成已生成过的文件
                .build();
        //初始化springboot操作
        springBootCli.initSpringBoot("根据指定表名称过滤不需要生成");
        //根据指定表名称生成对应的mybatis(如果generateController为true,也会生成对应的controller)
        springBootCli.createMybatis("根据指定表名称生成对应的mybatis");
    }

}

2)简单使用模板

public class Main {

    public static void main(String[] args) throws Exception {
        JdbcConfigEntity jdbcConfigEntity = new JdbcConfigEntity.Builder("mysql用户名", "mysql密码", "数据库名称")
                .build();
        SpringBootCli springBootCli = new SpringBootCli.Builder(Main.class, jdbcConfigEntity)
                .setUsePage(true)  
                .generateController(true)  
                .build();
        springBootCli.initSpringBoot( );
    }

}

4.下篇介绍springboot-dagger-x的详细使用,包含拦截器

你可能感兴趣的:(架构设计)