本文整理汇总了Java中org.mybatis.generator.config.xml.ConfigurationParser.parseConfiguration方法的典型用法代码示例。如果您正苦于以下问题:Java ConfigurationParser.parseConfiguration方法的具体用法?Java ConfigurationParser.parseConfiguration怎么用?Java ConfigurationParser.parseConfiguration使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mybatis.generator.config.xml.ConfigurationParser
的用法示例。
在下文中一共展示了ConfigurationParser.parseConfiguration方法的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: 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;
}
}
示例3: 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;
}
}
示例4: 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("运行成功!");
}
示例5: 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;
}
}
示例6: 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;
}
}
示例7: 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);
}
示例8: 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");
}
}
示例9: 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");
}
}
示例10: 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);
}
示例11: 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();
}
示例12: 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();
}
示例13: main
import org.mybatis.generator.config.xml.ConfigurationParser; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
List<String> warnings = new ArrayList<>();
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(
MapperGenerate.class.getResourceAsStream("/database/mybatis-generator-mapper-config.xml"));
DefaultShellCallback callback = new DefaultShellCallback(true);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
myBatisGenerator.generate(null);
}
示例14: 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;
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(
Generator.class.getResourceAsStream("/generator/generatorConfig.xml"));
DefaultShellCallback callback = new DefaultShellCallback(overwrite);
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
myBatisGenerator.generate(null);
}
示例15: create
import org.mybatis.generator.config.xml.ConfigurationParser; //导入方法依赖的package包/类
/**
* 创建
* @param resource
* @return
*/
public static MyBatisGeneratorTool create(String resource) throws IOException, XMLParserException {
MyBatisGeneratorTool tool = new MyBatisGeneratorTool();
tool.warnings = new ArrayList<>();
// MyBatisGenerator 创建
ConfigurationParser cp = new ConfigurationParser(tool.warnings);
tool.config = cp.parseConfiguration(Resources.getResourceAsStream(resource));
// 修正配置目标
tool.fixConfigToTarget();
return tool;
}