栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

SpringBoot+MyBatis

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

SpringBoot+MyBatis

SpringBoot 整合 MyBatis

依赖配置


    
        org.springframework.boot
        spring-boot-starter-web
    
    
        org.mybatis.spring.boot
        mybatis-spring-boot-starter
        2.2.0
    

    
        org.springframework.boot
        spring-boot-devtools
        runtime
        true
    
    
        mysql
        mysql-connector-java
        5.1.45
    
    
        org.projectlombok
        lombok
        true
    
    
        org.springframework.boot
        spring-boot-starter-test
        test
    
    
        org.springframework.boot
        spring-boot-starter-tomcat
    

    
        c3p0
        c3p0
        0.9.1.2
    



-- xml资源过滤

    
        
            src/main/java
            
                ****
            
        
        
        
        
        
        
        
        
    
    
        
            org.springframework.boot
            spring-boot-maven-plugin
            
                
                    
                        org.projectlombok
                        lombok
                    
                
            
        
    



yml配置
server:
  port: 80


spring:
  datasource:
    url: jdbc:mysql://localhost:3306/smbms?characterEncoding=utf-8
    username: root
    password: root
    driver-class-name: com.mysql.jdbc.Driver
  mvc:
    view:
      prefix: /WEB-INF/jsp/
      suffix: .jsp
mybatis:
  mapper-locations: classpath:cn/chy/com/main/mapper/*.xml
  type-aliases-package: classpath:cn/chy/com/main/pojo
  configuration:
      auto-mapping-behavior: full

#mapper-locations: classpath:cn/chy/com/main/mapper/*.xml配置也行吧 或者 启动类上@MapperScan

好了,最后在每个Mapper接口上定义@Mapper 注解 或 在启动类上添加 @MapperScan() 扫描

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/282441.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号