use of org.mybatis.generator.internal.DefaultShellCallback in project PublicCMS-preview by sanluan.
the class MybatisGenerator method main.
/**
* @param arg
* @throws Throwable
*/
public static void main(String[] arg) throws Throwable {
List<String> warnings = new ArrayList<>();
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(MybatisGenerator.class.getResourceAsStream("/generator/mybatis/generatorConfig.xml"));
DefaultShellCallback shellCallback = new DefaultShellCallback(true);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, shellCallback, warnings);
myBatisGenerator.generate(null);
}
use of org.mybatis.generator.internal.DefaultShellCallback in project jeesuite-libs by vakinge.
the class MyBatisGeneratorTool method main.
public static void main(String[] args) {
List<String> warnings = new ArrayList<String>();
boolean overwrite = true;
// src的一级目录下
String genCfg = "/generatorConfig.xml";
File configFile = new File(MyBatisGeneratorTool.class.getResource(genCfg).getFile());
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = null;
try {
config = cp.parseConfiguration(configFile);
} catch (IOException e) {
e.printStackTrace();
} catch (XMLParserException e) {
e.printStackTrace();
}
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
MyBatisGenerator myBatisGenerator = null;
try {
myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
} catch (InvalidConfigurationException e) {
e.printStackTrace();
}
try {
myBatisGenerator.generate(null);
} catch (SQLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
use of org.mybatis.generator.internal.DefaultShellCallback in project Resource by lovelifeming.
the class MBGTest method main.
public static void main(String[] args) throws Exception {
List<String> warnings = new ArrayList<String>();
boolean overwrite = true;
// 配置MyBatis generator配置文件
File configFile = new File("src/main/resources/MyBatisGenerator.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);
}
use of org.mybatis.generator.internal.DefaultShellCallback in project generator by mybatis.
the class GeneratorAntTask method execute.
@Override
public void execute() {
File configurationFile = calculateConfigurationFile();
Set<String> fullyqualifiedTables = calculateTables();
Set<String> contexts = calculateContexts();
List<String> warnings = new ArrayList<>();
try {
Properties p = propertyset == null ? null : propertyset.getProperties();
ConfigurationParser cp = new ConfigurationParser(p, warnings);
Configuration config = cp.parseConfiguration(configurationFile);
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
myBatisGenerator.generate(new AntProgressCallback(this, verbose), contexts, fullyqualifiedTables);
} catch (XMLParserException | InvalidConfigurationException e) {
for (String error : e.getErrors()) {
log(error, Project.MSG_ERR);
}
throw new BuildException(e.getMessage());
} catch (SQLException | IOException e) {
throw new BuildException(e.getMessage());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} catch (Exception e) {
log(e, Project.MSG_ERR);
throw new BuildException(e.getMessage());
}
for (String error : warnings) {
log(error, Project.MSG_WARN);
}
}
use of org.mybatis.generator.internal.DefaultShellCallback in project generator by mybatis.
the class JavaCodeGenerationTest method generateJavaFiles.
static List<GeneratedJavaFile> generateJavaFiles(String configFile) throws Exception {
List<String> warnings = new ArrayList<>();
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(JavaCodeGenerationTest.class.getResourceAsStream(configFile));
DefaultShellCallback shellCallback = new DefaultShellCallback(true);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, shellCallback, warnings);
myBatisGenerator.generate(null, null, null, false);
return myBatisGenerator.getGeneratedJavaFiles();
}
Aggregations