springboot整合tkmybatis和tkmybatis 逆向工程

1.添加依赖



    tk.mybatis
    mapper-spring-boot-starter
    2.0.3

打入mybatis.xml


    
        src/main/java
        
            **/*.xml
        
    
    
        src/main/resources
        
            **/*.properties
            **/*.xml
            **/*.tld
        
    

加入插件


    org.mybatis.generator
    mybatis-generator-maven-plugin
    
        
            tk.mybatis
            mapper
            3.5.0
        
    
    1.3.5
    
        
            Generate MyBatis Artifacts
            none
            
                generate
            
        
    

2.添加generatorConfig.xml mybatis的配置文件




    
    

    
    

    
        
            
            
            
        
        
        
            
            
        
        
       

        
        
            
        
        
        
            
            
            
            
            
            
            
            
            
            
        
        
        
            
            
            
            
            
            
        
        
        
        

3.添加application.properties

###########dubbo#######################
dubbo.application.name = dubbo-demo-server
dubbo.scan.basePackages= com.example.springbootProvider.provider
## RegistryConfig Bean
dubbo.registry.id = my-registry
dubbo.protocol.port=20880
dubbo.registry.address = zookeeper://www.shenzepengzuishuai.cn:2181?client=curator
mybatis.mapper-locations=classpath:/mapper/*.xml
 #####################################
server.port=8080
#配置数据源
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
#mysql的驱动程序类
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
#mybatis配置
mybatis.type-aliases-package=com.example.uniapp_test1.pojo
#连接池配置
spring.datasource.url=jdbc:mysql://xxxxx:3306/uniapp_test?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC&useSSL=false
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.dbcp2.min-idle=5
spring.datasource.dbcp2.initial-size=5
spring.datasource.dbcp2.max-idle=5
spring.datasource.dbcp2.max-wait-millis=200
#####################################

4.更改relativePath


    com.example
    springboot
    0.0.1-SNAPSHOT
    ../pom.xml 

5.添加druid依赖



    com.alibaba
    druid
    1.1.10

6.在mapper中添加公共mapper CommonMapper.java

    import tk.mybatis.mapper.common.Mapper;
    import tk.mybatis.mapper.common.MySqlMapper;
    
    
public interface CommonMapper extends Mapper, MySqlMapper {
}

7.在provider中的pom添加这个插件 因为在没有xml的情况下无法打包


    maven-war-plugin
    2.6
    
        
        false
    

 

你可能感兴趣的:(spring,boot,后端,java,mybatis,软件工程)