我有以下情况。当key在application.yml文件中不可用时,我想设置默认值。我总是看到null。请参见下面的代码。如果您看下面的代码,application.yml文件中的ios缺少元素label1,并且我正在使用@value注释设置默认值。如果您查看下面的TileConfig.java,我会将默认值设置为“它的android标签”,但是我总是将其设置为null。请帮助我解决此问题。谢谢!
tile:
responseConfig:
android:
label1: 'label1'
actionSwitch:
target: 'someurl'
method: 'PUT'
cin: '1'
actionLink:
target: 'target'
data:
EXTRA_UUID: '{accountId}'
ios:
actionSwitch:
target: 'someUrl'
method: 'PUT'
cin: '1'
actionLink:
target: 'target'
data:
EXTRA_UUID: '{accountId}'
@Configuration
@ConfigurationProperties(prefix = "tile.responseConfig")
public class TileConfig {
@Value("${tile.responseConfig.android.label1:its a Label}")
private String label1;
private Action actionSwitch;
private Action actionLink;
private Action actionSwitchForCard;
private Action actionLinkForCard;
public String getLabel1() {
return label1;
}
public void setLabel1(String label1) {
this.label1 = label1;
}