本文整理匯總了Java中org.mybatis.generator.internal.DefaultShellCallback類的典型用法代碼示例。如果您正苦於以下問題:Java DefaultShellCallback類的具體用法?Java DefaultShellCallback怎麽用?Java DefaultShellCallback使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
DefaultShellCallback類屬於org.mybatis.generator.internal包,在下文中一共展示了DefaultShellCallback類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: gen
import org.mybatis.generator.internal.DefaultShellCallback; //導入依賴的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.internal.DefaultShellCallback; //導入依賴的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.internal.DefaultShellCallback; //導入依賴的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: testGenerateInvalidConfigWithNoConnectionSources
import org.mybatis.generator.internal.DefaultShellCallback; //導入依賴的package包/類
@Test(expected=InvalidConfigurationException.class)
public void testGenerateInvalidConfigWithNoConnectionSources() throws Exception {
List<String> warnings = new ArrayList<String>();
Configuration config = new Configuration();
Context context = new Context(ModelType.HIERARCHICAL);
context.setId("MyContext");
config.addContext(context);
DefaultShellCallback shellCallback = new DefaultShellCallback(true);
try {
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, shellCallback, warnings);
myBatisGenerator.generate(null, null, null, false);
} catch (InvalidConfigurationException e) {
assertEquals(3, e.getErrors().size());
throw e;
}
}
示例5: testGenerateInvalidConfigWithTwoConnectionSources
import org.mybatis.generator.internal.DefaultShellCallback; //導入依賴的package包/類
@Test(expected=InvalidConfigurationException.class)
public void testGenerateInvalidConfigWithTwoConnectionSources() throws Exception {
List<String> warnings = new ArrayList<String>();
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);
try {
MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, shellCallback, warnings);
myBatisGenerator.generate(null, null, null, false);
} catch (InvalidConfigurationException e) {
assertEquals(3, e.getErrors().size());
throw e;
}
}
示例6: testGenerateMyBatis3WithInvalidConfig
import org.mybatis.generator.internal.DefaultShellCallback; //導入依賴的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;
}
}
示例7: onOK
import org.mybatis.generator.internal.DefaultShellCallback; //導入依賴的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("運行成功!");
}
示例8: generator
import org.mybatis.generator.internal.DefaultShellCallback; //導入依賴的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();
}
}
示例9: testGenerateMyBatis3
import org.mybatis.generator.internal.DefaultShellCallback; //導入依賴的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;
}
}
示例10: testGenerateIbatis2
import org.mybatis.generator.internal.DefaultShellCallback; //導入依賴的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;
}
}
示例11: generator
import org.mybatis.generator.internal.DefaultShellCallback; //導入依賴的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);
}
示例12: testGenerateMyBatis3
import org.mybatis.generator.internal.DefaultShellCallback; //導入依賴的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");
}
}
示例13: testGenerateIbatis2
import org.mybatis.generator.internal.DefaultShellCallback; //導入依賴的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");
}
}
示例14: generator
import org.mybatis.generator.internal.DefaultShellCallback; //導入依賴的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);
}
示例15: MyBatisGenerator
import org.mybatis.generator.internal.DefaultShellCallback; //導入依賴的package包/類
/**
* Constructs a MyBatisGenerator object.
*
* @param configuration
* The configuration for this invocation
* @param shellCallback
* an instance of a ShellCallback interface. You may specify
* <code>null</code> in which case the DefaultShellCallback will
* be used.
* @param warnings
* Any warnings generated during execution will be added to this
* list. Warnings do not affect the running of the tool, but they
* may affect the results. A typical warning is an unsupported
* data type. In that case, the column will be ignored and
* generation will continue. You may specify <code>null</code> if
* you do not want warnings returned.
* @throws InvalidConfigurationException
* if the specified configuration is invalid
*/
public MyBatisGenerator(Configuration configuration, ShellCallback shellCallback,
List<String> warnings) throws InvalidConfigurationException {
super();
if (configuration == null) {
throw new IllegalArgumentException(getString("RuntimeError.2")); //$NON-NLS-1$
} else {
this.configuration = configuration;
}
if (shellCallback == null) {
this.shellCallback = new DefaultShellCallback(false);
} else {
this.shellCallback = shellCallback;
}
if (warnings == null) {
this.warnings = new ArrayList<String>();
} else {
this.warnings = warnings;
}
generatedJavaFiles = new ArrayList<GeneratedJavaFile>();
generatedXmlFiles = new ArrayList<GeneratedXmlFile>();
projects = new HashSet<String>();
this.configuration.validate();
}