Spring 中的 systemProperties 是什么以及在哪里可以找到它?

What is systemProperties in Spring and where to find it?

我正在读 Spring In Action 一本书,其中有一个例子:

public BlankDisc(@Value("#{systemProperties['disc.title']}" String title){
}

但是这里 systemProperties 是什么,在哪里声明呢?我认为这是 application.properties 文件并在其中添加了 disc.title=Beatles。但是创建bean时title变量的值是null。如果我顺便使用@Value("${disc.title}"),我可以注入disc.title的值。

这是将在启动 jar 时设置的 属性,如 "java -Dproperty.name="value" -jar app.jar"

例如,如果您 运行 申请 java -jar app.jar -Dmy.param=myParam

然后你可以创建bean

@Bean
public String myParam(){
   return System.getProperty("my.param");
}

并通过@Autowiere

注入