mybatisGenerator的配置文件生成代码

2020-03-26  本文已影响0人  leimelon

@Testpublic void test11(){

ArrayList<String> warings = new ArrayList<String>();

boolean overwrite=true;

String getConfig="/generatorConfig.xml";

File file = new File(test1.class.getResource(getConfig).getFile());

ConfigurationParser configurationParser = new ConfigurationParser(warings);

Configuration configuration=null;

try {

configuration = configurationParser.parseConfiguration(file);

} catch (IOException e) {

e.printStackTrace();

} catch (XMLParserException e) {

e.printStackTrace();

}

DefaultShellCallback defaultShellCallback = new DefaultShellCallback(overwrite);

MyBatisGenerator myBatisGenerator=null;

try {

myBatisGenerator = new MyBatisGenerator(configuration,defaultShellCallback,warings);

} catch (InvalidConfigurationException e) {

e.printStackTrace();

} try {

myBatisGenerator.generate(null);

} catch (SQLException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

} catch (InterruptedException e) {

e.printStackTrace();

}

}

上一篇 下一篇

猜你喜欢

热点阅读