com.github.fanzezhen.generator.MysqlGenerator Maven / Gradle / Ivy
package com.github.fanzezhen.generator;
import lombok.NoArgsConstructor;
import java.lang.reflect.InvocationTargetException;
/**
*
* mysql 代码生成器演示例子
*
*
* @author jobob
* @since 2018-09-12
*/
@NoArgsConstructor
public class MysqlGenerator extends GeneratorBean {
@Override
public void init() {
setDataSourceConfigUrl("jdbc:mysql://localhost:3306/demo?useSSL=false&useUnicode=true&characterEncoding=UTF-8");
setDriverName("com.mysql.cj.jdbc.Driver");
setDbUsername("root");
setDbPassword("a123456");
setModulePackageName("com.github.fanzezhen.generator");
}
public MysqlGenerator(String dataSourceConfigUrl, String dbUsername, String dbPassword, String moduleName,
String modulePackageName) {
setDataSourceConfigUrl(dataSourceConfigUrl);
setDbUsername(dbUsername);
setDbPassword(dbPassword);
setModuleName(moduleName);
setModulePackageName(modulePackageName);
}
public MysqlGenerator(String dataSourceConfigUrl, String dbUsername, String dbPassword, String moduleName,
String modulePackageName, String superEntityClassName) {
setDataSourceConfigUrl(dataSourceConfigUrl);
setDbUsername(dbUsername);
setDbPassword(dbPassword);
setModuleName(moduleName);
setModulePackageName(modulePackageName);
setSuperEntityClassName(superEntityClassName);
}
public MysqlGenerator(String dataSourceConfigUrl, String dbUsername, String dbPassword, String moduleName,
String modulePackageName, String superEntityClassName, String... superEntityColumns) {
setDataSourceConfigUrl(dataSourceConfigUrl);
setDbUsername(dbUsername);
setDbPassword(dbPassword);
setModuleName(moduleName);
setModulePackageName(modulePackageName);
setSuperEntityClassName(superEntityClassName);
setSuperEntityColumns(superEntityColumns);
}
public MysqlGenerator(String author, String dataSourceConfigUrl, String driverName, String dbUsername, String dbPassword,
String packageName, String modulePackageName, String tableNameSplitter, String tables) {
setAuthor(author);
setDataSourceConfigUrl(dataSourceConfigUrl);
setDriverName(driverName);
setDbUsername(dbUsername);
setDbPassword(dbPassword);
setPackageName(packageName);
setModulePackageName(modulePackageName);
setTableNameSplitter(tableNameSplitter);
setTables(tables);
}
/**
* RUN THIS
*/
public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
GeneratorTool.generator(MysqlGenerator.class.getConstructor().newInstance());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy