【发布时间】:2018-01-08 18:12:04
【问题描述】:
我正在尝试获取属性的值
hello.world=Hello World
在 MainApp 类中
@SpringBootApplication
public class MainApp {
public static void main(String[] args) {
SpringApplication.run(MainApp.class, args);
}
这不是它的主要方法。
@Value("${hello.world}")
public static String helloWorld;
也许它可以加载
Properties prop = new Properties();
// load a properties file
prop.load(new FileInputStream(filePath));
在SpringApplication.run之前在SpringBoot的main方法中使用Spring获取属性还有其他更好的方法吗
【问题讨论】:
-
为什么在上下文运行之前需要这些信息?
标签: spring spring-boot