springboot-数据访问
生活随笔
收集整理的這篇文章主要介紹了
springboot-数据访问
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
文章目錄
- 整合測試
- 整合第三方技術
- 1.自定義
- 2.找starter
- 整合mybatis
整合測試
application.yaml
spring:datasource:url: jdbc:mysql://localhost:3306/bookusername: rootpassword: 12345driver-class-name: com.mysql.jdbc.DriverBoot05WebAdminApplicationTests
@Slf4j @SpringBootTest class Boot05WebAdminApplicationTests {@AutowiredJdbcTemplate jdbcTemplate;@Testvoid contextLoads() {// jdbcTemplate.queryForList("select * from t_book");Long aLong = jdbcTemplate.queryForObject("select count(*) from t_book", Long.class);System.out.println(aLong);log.info("記錄總數(shù):{}",aLong);}}整合第三方技術
1.自定義
引入依賴
<dependency><groupId>com.alibaba</groupId><artifactId>druid</artifactId><version>1.1.17</version></dependency>2.找starter
整合mybatis
總結(jié)
以上是生活随笔為你收集整理的springboot-数据访问的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: springboot-web开发
- 下一篇: 申请个人阿里云镜像