SpringBoot 获取自定义yml文件中的内容

    技术2025-02-04  7

    开发时有时需要读取自定义的yml文件 可以使用@PropertySource + @Value读取其中的内容

    test.yml name: Saber testUtil.java @PropertySource(value = "classpath:test.yml") public class testUtil{ @Value("${name}") private String name; }
    Processed: 0.009, SQL: 9