自定义配置文件
mytest1: 测试数据
加载自定义配置文件指定编码格式
@SpringBootApplication
@PropertySource(value = "classpath:aaa.yml",ignoreResourceNotFound=true,encoding = "UTF-8")
public class SpringbootApplication {
@Value("${mytest}")
private String mytest;
public static void main(String[] args) {
SpringApplication.run(SpringbootApplication.class, args);
}
}
测试
@SpringBootTest
class SpringbootApplicationTests {
@Value("${mytest1}")
private String mytest1;
@Test
void text1(){
System.out.println(mytest1);
}
}