第二节: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) 数据源的自动装配


1.4.2) jdbcTemplate自动装配

temp

image-20210604173338153

image-20210604180347133

image-20210604185902059

posted @ 2021-06-04 19:31  傀儡岁月  阅读(101)  评论(0编辑  收藏  举报