use of org.mybatis.generator.internal.DefaultShellCallback in project spring-boot-api-seed-project by selfassu.
the class CodeGenerator method generator.
private void generator() throws Exception {
List<String> warnings = new ArrayList<String>();
System.out.println("====开始读取配置文件======");
File configFile = new File(CONFIG_PATH);
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(configFile);
DefaultShellCallback callback = new DefaultShellCallback(true);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
myBatisGenerator.generate(null);
}
use of org.mybatis.generator.internal.DefaultShellCallback in project dubidubi by lzzzz4.
the class Start method generator.
public void generator() throws Exception {
List<String> warnings = new ArrayList<>();
boolean overwrite = true;
// 指定 逆向工程配置文件
// File configFile = new File("generatorConfig.xml");
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("generatorConfig.xml");
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(inputStream);
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
myBatisGenerator.generate(null);
}
use of org.mybatis.generator.internal.DefaultShellCallback in project java-code-show by CodeShowZz.
the class UserDaoTest method insertTest.
@Test
public void insertTest() throws IOException, XMLParserException, InvalidConfigurationException, SQLException, InterruptedException {
String fileName = this.getClass().getClassLoader().getResource("generatorConfig.xml").getFile();
File configFile = new File(fileName);
List<String> warnings = new ArrayList<String>();
boolean overwrite = true;
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 tutorials-java by Artister.
the class MybatisGenerator method generateStubs.
protected void generateStubs(String... tableNames) throws Exception {
if (ArrayUtils.isEmpty(tableNames)) {
_LOGGER.info("no table name was specified");
return;
}
makeXml(tableNames);
File configFile = new File(mbgXmlPath);
List<String> warnings = new ArrayList<>();
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(configFile);
DefaultShellCallback callback = new DefaultShellCallback(true);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
myBatisGenerator.generate(null);
_LOGGER.info("mybatis generated done !");
}
use of org.mybatis.generator.internal.DefaultShellCallback in project generator by mybatis.
the class MyBatisGeneratorTest method testGenerateInvalidConfigWithTwoConnectionSources.
@Test
void testGenerateInvalidConfigWithTwoConnectionSources() {
List<String> warnings = new ArrayList<>();
Configuration config = new Configuration();
Context context = new Context(ModelType.HIERARCHICAL);
context.setId("MyContext");
context.setConnectionFactoryConfiguration(new ConnectionFactoryConfiguration());
context.setJdbcConnectionConfiguration(new JDBCConnectionConfiguration());
config.addContext(context);
DefaultShellCallback shellCallback = new DefaultShellCallback(true);
InvalidConfigurationException e = assertThrows(InvalidConfigurationException.class, () -> {
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, shellCallback, warnings);
myBatisGenerator.generate(null, null, null, false);
});
assertEquals(3, e.getErrors().size());
}
Aggregations