【发布时间】:2016-04-04 09:50:09
【问题描述】:
Spring 配置文件中是否可以有布尔值?
我在我的 bean 中写了以下字段:
@Value("${pdk.populatedemo}")
private boolean populateDemo;
但如果导致以下异常:
Could not autowire field: private boolean com.inthemoon.pdk.data.DatabaseService.populateDemo; nested exception is org.springframework.beans.TypeMismatchException:
Failed to convert value of type [java.lang.String] to required type [boolean]; nested exception is java.lang.IllegalArgumentException:
Invalid boolean value [1;]
我试过了
pdk.populatedemo=1;
在application.properties。我还尝试了=true 和其他一些。
【问题讨论】:
-
in
application.properties我也试过=true末尾有分号 ?
标签: java spring properties-file