mybatis中的逆向工程

一、导入的jar包
log4j-1.2.16.jar
mybatis-3.2.3.jar
mybatis-generator-core-1.3.2.jar
mysql-connector-java-5.1.28-bin.jar
ojdbc14.jar



二、生成代码的配置文件




    
        
            
            
        
        
        
        
        

        
        
            
        

        
        
            
            
            
            
        
        
        
            
            
        
        
        
            
            
        
        
        


三、执行生成程序
public class GeneratorSqlmap {
    public void generator() throws Exception{
        List warnings = new ArrayList();
        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);
    }
    
    public static void main(String []args) throws Exception {
        try{
            GeneratorSqlmap generatorSqlmap = new GeneratorSqlmap();
            generatorSqlmap.generator();
        } catch (Exception e){
            e.printStackTrace();
        }
    }
}



最后推荐大家一个非常好的文章:关于java用户角色权限设计

http://www.open-open.com/lib/view/open1413272655903.html








你可能感兴趣的:(java-MyBetis)