mybatis-generator-maven-plugin(MyBatis 逆向工程 插件)

这里介绍一种与eclipse ibator 逆向工程插件功能类似的maven插件,即 mybatis-generator-maven-plugin,它可逆向快速生成基础代码,提高开发效率。eclipse ibator插件

  1. maven 父工程dependency版本控制
    
        5.1.41
        1.3.2
        1.3.5
        1.1.6
    
    
        
    	mysql
            mysql-connector-java
    	${mysql-connector-java.version}
        
        
    	org.mybatis.spring.boot
    	mybatis-spring-boot-starter
    	${mybatis-spring-boot-starter.version}
        
        
    	org.mybatis.generator
    	mybatis-generator-maven-plugin
    	${mybatis-generator-maven-plugin.version}
        
        
    	com.alibaba
    	druid-spring-boot-starter
    	${druid-starter.version}
        
    

     

  2. 子工程引用maven插件
    
        
            
    	
    	    org.mybatis.generator
    	    mybatis-generator-maven-plugin
    	    
    		
    		    mysql
    		    mysql-connector-java
    		    ${mysql-connector-java.version}
    		
    	    
    	    
    		
    		    Generate MyBatis Artifacts
    		    package
    		    
    			generate
    		    
    		
    	    
    	    
    		
    		true
    		
    		true
    		
    		
    		    src/main/resources/config/generator-config.xml
    		
    	    
    	
        
    

     

  3. classpath:resources下config文件夹中创建generator-config.xml
    
    
    
        
        
        
    
        
            
            
                
                
                
                
            
    
            
            
            
    
            
            
            
                
                
                
                
            
    
            
            
                
                
                
                
            
    
            
            
                
                
            
    
            
            
                
                
            
    
            
            
            

     

  4. classpath:resources下config文件夹中创建application.properties
    #mysql配置
    spring.datasource.url=jdbc:mysql://****:3306/basic_server?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true
    spring.datasource.username=root
    spring.datasource.password=****
    spring.datasource.driver-class-name=com.mysql.jdbc.Driver
    spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
    
    #alibaba DruidDataSource 配置
    spring.datasource.druid.initialSize=5
    spring.datasource.druid.minIdle=5
    spring.datasource.druid.maxActive=30
    # 配置获取连接等待超时的时间
    spring.datasource.maxWait=60000
    #Druid监控配置
    spring.datasource.druid.WebStatFilter.exclusions=*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*
    spring.datasource.druid.StatViewServlet.loginUsername=druid
    spring.datasource.druid.StatViewServlet.loginPassword=druid
    
    #mybatis配置
    mapper.mappers=com.spring_cloud.base_server.repository
    
    # Generator配置
    generator.targetProject=src/main/java
    #生成接口位置
    generator.mappers=com.spring_cloud.base_server.repository
    #生成pojo位置
    generator.javaModel-targetPackage=com.spring_cloud.base_server.bean
    #生成mapper位置
    generator.sqlMap-targetPackage=com.spring_cloud.base_server.repository

     

  5. maven install即可生成pojo、pojoExample、pojoMapper接口(缺少@mapper注释,手动添加)、pojoMapper.xml,Ipojoservice与pojoserverImpl手动添加,到这里就结束了。

你可能感兴趣的:(mybatis-generator-maven-plugin(MyBatis 逆向工程 插件))