当前位置: 首页>>代码示例>>Java>>正文


Java DefaultShellCallback类代码示例

本文整理汇总了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();
    }
}
 
开发者ID:ychaoyang,项目名称:autotest,代码行数:24,代码来源:Dalgen.java

示例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;
    }
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:17,代码来源:MyBatisGeneratorTest.java

示例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;
    }
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:17,代码来源:MyBatisGeneratorTest.java

示例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;
    }
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:19,代码来源:MyBatisGeneratorTest.java

示例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;
    }
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:21,代码来源:MyBatisGeneratorTest.java

示例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;
    }
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:17,代码来源:MyBatisGeneratorTest.java

示例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("运行成功!");
}
 
开发者ID:Yanweichen,项目名称:MybatisGeneatorUtil,代码行数:18,代码来源:Main.java

示例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();  
    }  
      
}
 
开发者ID:KeithLaiKB,项目名称:SpringMvcMavenDB,代码行数:19,代码来源:GeneratorExecution.java

示例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;
    }
}
 
开发者ID:backkoms,项目名称:mybatis-generator-comments,代码行数:17,代码来源:MyBatisGeneratorTest.java

示例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;
    }
}
 
开发者ID:backkoms,项目名称:mybatis-generator-comments,代码行数:17,代码来源:MyBatisGeneratorTest.java

示例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);

	}
 
开发者ID:MyCATApache,项目名称:Mycat-openEP,代码行数:17,代码来源:GeneratorSqlmap.java

示例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");
    }
}
 
开发者ID:fnyexx,项目名称:mybator,代码行数:22,代码来源:MyBatisGeneratorTest.java

示例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");
    }
}
 
开发者ID:fnyexx,项目名称:mybator,代码行数:22,代码来源:MyBatisGeneratorTest.java

示例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);

	}
 
开发者ID:ChenXcc,项目名称:taotao-shop,代码行数:15,代码来源:GeneratorSqlmap.java

示例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();
}
 
开发者ID:bandaotixi,项目名称:generator_mybatis,代码行数:46,代码来源:MyBatisGenerator.java


注:本文中的org.mybatis.generator.internal.DefaultShellCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。