springboot(4)- yaml 配置

1 yaml 配置

  • yaml配置是有序的,properties 配置是无序的
  • 自定义的yaml 目前暂时不支持使用注解直接注入到 spring boot 项目

在这里插入图片描述


在这里插入图片描述

1.1 yaml 注入属性

在这里插入图片描述
在这里插入图片描述

  • 单元测试
@SpringBootTest
class SpringbootTestApplicationTests {

    @Autowired
    private RedisCluster cluster;

    @Test
    void contextLoads() {
        System.out.println("redis配置: "+ cluster);
    }
}

在这里插入图片描述

1.2 注入对象

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述


  • 单元测试
@SpringBootTest
class SpringbootTestApplicationTests {

    @Autowired
    private RedisCluster cluster;

    @Test
    void contextLoads() {
        System.out.println("redis配置: "+ cluster);
    }
}

在这里插入图片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章