@Component
@EnableConfigurationProperties
@ConfigurationProperties("audit")
@Setter
@Getter
public class PlannerPropertyReader {
@Value("#{'${audit.planner.collection-blacklist}'.split(',')}")
private List<String> blacklistCollection;
}
在这里
audit.planner
audit.planner.collection-blacklist
不存在于应用程序属性文件。因此它抛出
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'plannerPropertyReader': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'audit.planner.collection-blacklist' in value "#{'${audit.planner.collection-blacklist}'.split(',')}"
如果@value中的属性无法解析,如何设置默认值?