Spring Boot 数据访问
1、整合JDBC <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> yaml spring: datasource: username: root password: 123456 url: jdbc:mysql://localhost:3306/jdbc driver-class-name: com.mysql.cj.jdbc.Driver initialization-mode: always 效果: 默认是用org.apache.tomcat.jdbc.pool.DataSource作为数据源; 数据源的相关配置都在DataSourceProperties里面; 自动配置原理: org.springframework.boot.autoconfigure.jdbc: 1、参考DataSourceConfiguration,根据配置创建数据源