springboot+mybatis-plus 代码生成器代码生成器 CRUD 分页插件分页插件
1 添加mybatis-plus相关依赖
com.baomidou
mybatis-plus-boot-starter
3.1.1
com.baomidou
mybatis-plus-generator
3.1.1
org.apache.velocity
velocity-engine-core
2.1
org.projectlombok
lombok
1.16.10
2 配置application.properties
#编码格式
#server.tomcat.uri-encoding=utf-8
#数据库相关配置
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url = jdbc:mysql://localhost:3306/orcl?serverTimezone=UTC&useUnicode=true&characterEncoding=UTF-
8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false
spring.datasource.username=root
spring.datasource.password=
spring.datasource.max-idle=10
spring.datasource.max-wait=10000
spring.datasource.min-idle=5
spring.datasource.initial-size=5
3.生成代码类(可自动生成entity、controller、service、mapper)
public class CodeGenerator {
/**
*
* 读取控制台内容
*
*/
public static String scanner(String tip) {
Scanner scanner = new Scanner(System.in);
StringBuilder help = new StringBuilder();
help.append("请输入" + tip + ":");
System.out.println(help.toString());
if (scanner.hasNext()) {
String ipt = scanner.next();
if (StringUtils.isNotEmpty(ipt)) {
return ipt;
}
}
throw new MybatisPlusException("请输入正确的" + tip + "!");
}
public static void main(String[] args) {
// 代码生成器
AutoGenerator mpg = new AutoGenerator();
// 全局配置
GlobalConfig gc = new GlobalConfig();
String projectPath = System.getProperty("user.dir");
gc.setOutputDir(projectPath + "/src/main/java");
gc.setAuthor("lane");
评论0
最新资源