1.创建springboot工程,pom文件主要包:
2.application.proprities中数据源配置:
3.application.proprities中mybatis配置:
mybatis.configuration.map-underscore-to-camel-case=true:作用是将数据库字段是下划线,改变为程序中使用驼峰
mybatis.mapper-locations:配置mapper.xml的文件扫描路径
4.在SpringBootApplication类文件添加自动扫描注解:
5.mapper接口主要内容:
6.mapper.xml接口主要内容:
需要了解知识点
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的关联信息