本文整理汇总了Java中org.mybatis.generator.config.xml.ConfigurationParser类的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationParser类的具体用法?Java ConfigurationParser怎么用?Java ConfigurationParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ConfigurationParser类属于org.mybatis.generator.config.xml包,在下文中一共展示了ConfigurationParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: gen
import org.mybatis.generator.config.xml.ConfigurationParser; //导入依赖的package包/类
public void gen() {
logger.info("开始执行mybatis代码生成工具");
List<String> warnings = new ArrayList<>();
/*覆盖原生成的代码*/
boolean overwrite = true;
try {
ConfigurationParser cp = new ConfigurationParser(warnings);
config = cp.parseConfiguration(Dalgen.class.getClassLoader().getResourceAsStream(
propertiesLocation));
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
myBatisGenerator.generate(null);
if (warnings.size() != 0) {
logger.info("请注意下面的警告");
}
for (String warning : warnings) {
logger.info(warning);
}
logger.info("代码生成完成");
} catch (Exception e) {
e.printStackTrace();
}
}
示例2: testGenerateMyBatis3WithInvalidConfig
import org.mybatis.generator.config.xml.ConfigurationParser; //导入依赖的package包/类
@Test(expected=InvalidConfigurationException.class)
public void testGenerateMyBatis3WithInvalidConfig() throws Exception {
List<String> warnings = new ArrayList<String>();
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(this.getClass().getClassLoader().getResourceAsStream("generatorConfigMyBatis3_badConfig.xml"));
DefaultShellCallback shellCallback = new DefaultShellCallback(true);
try {
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, shellCallback, warnings);
myBatisGenerator.generate(null, null, null, true);
} catch (InvalidConfigurationException e) {
assertEquals(2, e.getErrors().size());
throw e;
}
}
示例3: testGenerateIbatis2WithInvalidConfig
import org.mybatis.generator.config.xml.ConfigurationParser; //导入依赖的package包/类
@Test(expected=InvalidConfigurationException.class)
public void testGenerateIbatis2WithInvalidConfig() throws Exception {
List<String> warnings = new ArrayList<String>();
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(this.getClass().getClassLoader().getResourceAsStream("generatorConfigIbatis2_badConfig.xml"));
DefaultShellCallback shellCallback = new DefaultShellCallback(true);
try {
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, shellCallback, warnings);
myBatisGenerator.generate(null, null, null, false);
} catch (InvalidConfigurationException e) {
assertEquals(1, e.getErrors().size());
throw e;
}
}
示例4: testGenerateMyBatis3WithInvalidConfig
import org.mybatis.generator.config.xml.ConfigurationParser; //导入依赖的package包/类
@Test(expected=InvalidConfigurationException.class)
public void testGenerateMyBatis3WithInvalidConfig() throws Exception {
List<String> warnings = new ArrayList<String>();
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(this.getClass().getClassLoader().getResourceAsStream("generatorConfigMyBatis3_badConfig.xml"));
DefaultShellCallback shellCallback = new DefaultShellCallback(true);
try {
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, shellCallback, warnings);
myBatisGenerator.generate(null, null, null, false);
} catch (InvalidConfigurationException e) {
assertEquals(2, e.getErrors().size());
throw e;
}
}
示例5: onOK
import org.mybatis.generator.config.xml.ConfigurationParser; //导入依赖的package包/类
private void onOK() throws Exception {
Main.this.setTitle("正在运行...");
FileUtils.deleteDirectory( new File("src"));
File dir = new File("src");
if (!dir.exists()) {
dir.mkdir();
}
List<String> warnings = new ArrayList<String>();
boolean overwrite = true;
ConfigurationParser cp = new ConfigurationParser(warnings);
FileInputStream fileInputStream = new FileInputStream("generatorConfig.xml");
Configuration config = cp.parseConfiguration(fileInputStream);
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
myBatisGenerator.generate(null);
Main.this.setTitle("运行成功!");
}
示例6: generator
import org.mybatis.generator.config.xml.ConfigurationParser; //导入依赖的package包/类
public static void generator(){
List<String> warnings=new ArrayList<String>();
try {
//specify the location of the config file to generator
File configFile=new File("./src/main/resources/mybatis/mybatis-generator/mybatis-generator.xml");
//parser the file
ConfigurationParser cp=new ConfigurationParser(warnings);
Configuration config=cp.parseConfiguration(configFile);
//set whether the file could be override
DefaultShellCallback dsc=new DefaultShellCallback(true);
MyBatisGenerator mg=new MyBatisGenerator(config, dsc, warnings);
mg.generate(null);
} catch (Exception e) {
e.printStackTrace();
}
}
示例7: testGenerateMyBatis3
import org.mybatis.generator.config.xml.ConfigurationParser; //导入依赖的package包/类
@Test(expected=InvalidConfigurationException.class)
public void testGenerateMyBatis3() throws Exception {
List<String> warnings = new ArrayList<String>();
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(this.getClass().getClassLoader().getResourceAsStream("generatorConfigMyBatis3.xml"));
DefaultShellCallback shellCallback = new DefaultShellCallback(true);
try {
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, shellCallback, warnings);
myBatisGenerator.generate(null);
} catch (InvalidConfigurationException e) {
assertEquals(2, e.getErrors().size());
throw e;
}
}
示例8: testGenerateIbatis2
import org.mybatis.generator.config.xml.ConfigurationParser; //导入依赖的package包/类
@Test(expected=InvalidConfigurationException.class)
public void testGenerateIbatis2() throws Exception {
List<String> warnings = new ArrayList<String>();
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(this.getClass().getClassLoader().getResourceAsStream("generatorConfigIbatis2.xml"));
DefaultShellCallback shellCallback = new DefaultShellCallback(true);
try {
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, shellCallback, warnings);
myBatisGenerator.generate(null);
} catch (InvalidConfigurationException e) {
assertEquals(1, e.getErrors().size());
throw e;
}
}
示例9: generator
import org.mybatis.generator.config.xml.ConfigurationParser; //导入依赖的package包/类
public void generator() throws Exception {
List<String> warnings = new ArrayList<String>();
boolean overwrite = true;
// 指定 逆向工程配置文件
String resource = Thread.currentThread().getContextClassLoader()
.getResource("generatorConfig.xml").toString().substring(6);
System.out.println(resource);
File configFile = new File(resource);
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);
}
示例10: testGenerateMyBatis3
import org.mybatis.generator.config.xml.ConfigurationParser; //导入依赖的package包/类
@Test
public void testGenerateMyBatis3() throws Exception {
List<String> warnings = new ArrayList<String>();
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(this.getClass().getClassLoader().getResourceAsStream("generatorConfigMyBatis3.xml"));
DefaultShellCallback shellCallback = new DefaultShellCallback(true);
boolean gotException = false;
try {
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, shellCallback, warnings);
myBatisGenerator.generate(null);
} catch (InvalidConfigurationException e) {
assertEquals(3, e.getErrors().size());
gotException = true;
}
if (!gotException) {
fail("Should throw InvalidConfigurationException");
}
}
示例11: testGenerateIbatis2
import org.mybatis.generator.config.xml.ConfigurationParser; //导入依赖的package包/类
@Test
public void testGenerateIbatis2() throws Exception {
List<String> warnings = new ArrayList<String>();
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(this.getClass().getClassLoader().getResourceAsStream("generatorConfigIbatis2.xml"));
DefaultShellCallback shellCallback = new DefaultShellCallback(true);
boolean gotException = false;
try {
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, shellCallback, warnings);
myBatisGenerator.generate(null);
} catch (InvalidConfigurationException e) {
assertEquals(1, e.getErrors().size());
gotException = true;
}
if (!gotException) {
fail("Should throw InvalidConfigurationException");
}
}
示例12: generator
import org.mybatis.generator.config.xml.ConfigurationParser; //导入依赖的package包/类
public void generator() throws Exception{
List<String> warnings = new ArrayList<String>();
boolean overwrite = true;
//指定 逆向工程配置文件
File configFile = new File("generatorConfig.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);
}
示例13: generateJavaFiles
import org.mybatis.generator.config.xml.ConfigurationParser; //导入依赖的package包/类
private static List<GeneratedJavaFile> generateJavaFiles(String configFile) throws Exception {
List<String> warnings = new ArrayList<String>();
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();
}
示例14: generateXmlFiles
import org.mybatis.generator.config.xml.ConfigurationParser; //导入依赖的package包/类
private static List<GeneratedXmlFile> generateXmlFiles(String configFile) throws Exception {
List<String> warnings = new ArrayList<String>();
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.getGeneratedXmlFiles();
}
示例15: main
import org.mybatis.generator.config.xml.ConfigurationParser; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
List<String> warnings = new ArrayList<String>();
boolean overwrite = true;
File configFile = new File("generatorConfig.xml");
ConfigurationParser cp = new ConfigurationParser(warnings);
org.mybatis.generator.config.Configuration config = cp.parseConfiguration(configFile);
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config,
callback, warnings);
myBatisGenerator.generate(null);
}