1.创建springboot工程,pom文件主要包:

  SpringBoot学习之配置MyBatis

2.application.proprities中数据源配置:

  SpringBoot学习之配置MyBatis

3.application.proprities中mybatis配置:

  SpringBoot学习之配置MyBatis

  mybatis.configuration.map-underscore-to-camel-case=true:作用是将数据库字段是下划线,改变为程序中使用驼峰

  mybatis.mapper-locations:配置mapper.xml的文件扫描路径

4.在SpringBootApplication类文件添加自动扫描注解:

  SpringBoot学习之配置MyBatis

5.mapper接口主要内容:

  SpringBoot学习之配置MyBatis

6.mapper.xml接口主要内容:

  SpringBoot学习之配置MyBatis

 

需要了解知识点

1.@MapperScan:告诉springboot框架扫描指定包下的mapper接口,通常该注解使用在config类中

2.@Mapper:告诉springboot框架扫描指定mapper接口,通常该注解使用在某个mapper接口上

3.如果使用mapper.xml编写sql与mapper接口关联那么需要在application.properties配置:mybatis.mapper-locations = classpath*:com/smc/sso/mapper/*.xml

4.如果使用注解的方式在接口中编写sql那么就能在application.properties配置xml的关联信息

    

 

相关文章:

  • 2021-10-24
  • 2022-12-23
  • 2022-02-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-19
  • 2021-07-27
  • 2021-09-19
  • 2022-12-23
  • 2021-06-22
相关资源
相似解决方案