spring boot使用注解的方式整合mybaits
生活随笔
收集整理的這篇文章主要介紹了
spring boot使用注解的方式整合mybaits
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
使用注解整和mybatis,不需要任何的xml注釋,只需要在
@SpringBootApplication
加上一行mapper的掃描文件即可
在application.properties配置
server.port=8000 server.context-path=/test#編碼格式 server.tomcat.uri-encoding=utf-8#數據庫相關配置 spring.datasource.url=jdbc:mysql://localhost:3306/mybatis?serverTimezone=CST spring.datasource.username=root spring.datasource.password=123456 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver然后正常的四個文件結構
注解: ## controller ```php@Autowiredprivate UserService userService;service實體類
@Service("userService")@Autowiredprivate UserMapper userMapper;mapper
@Repository總結
以上是生活随笔為你收集整理的spring boot使用注解的方式整合mybaits的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 如何检测电脑所少驱动?
- 下一篇: 电脑检测不到添加的硬件是什么问题?