第二节:springboot整合篇(飞机篇)
目录
1:springboot整合jdbc
1.1:导入的maven依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.46</version>
<scope>runtime</scope>
</dependency>
1.2:配置相关数据源:
spring:
datasource:
username: root
data-password: root
url: jdbc:mysql://127.0.0.1:3306/tuling-vip
driver-class-name: com.mysql.jdbc.Driver
1.3:测试
@Autowired
private DataSource dataSource;
@Test
public void contextLoads() {
}
@Test
public void testDbType() {
System.out.println("自动装配数据源的类型:"+dataSource.getClass());
}
1.4) jdbc 以及数据源的自动装配原理
1.4.1) 数据源的自动装配