@PropertySource实现配置文件加载
示例如下:
epp.properties
gaga=1010101
SpringBootConfigApplicationTests.java
@SpringBootTest
@PropertySource(value="classpath:epp.properties")
class SpringBoot02ConfigApplicationTests {
@Value("${gaga}")
private String gaga;
@Test
void contextLoads() {
System.out.println("gaga:"+gaga);
}
}
打印结果如下:
gaga:1010101