我正在尝试获取属性的值
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));
在SpringBoot的main方法中,在SpringApplication.run之前,有没有其他更好的方法来使用Spring获取属性?