从属性文件中自动装配布尔基元

Ani*_*dha 11 spring autowired

嗨我想从属性文件autowire boolean值已经引用以下链接与地图url Spring属性(property-placeholder)自动装配

但我想自动连接一个布尔属性,也提到了问题Spring Autowire原始布尔 Spring Autowire原始布尔值, 但那是bean值,在我的情况下我想使用点分隔的属性值做同样的事情.

${does.it.allow} //它失败,并给出字符串不能转换为boolean #{does.it.allow} //这给用名称来定义无豆/属性确实,但我有正确的属性文件,它证明了容器能够加载它,因为第一个错误.

Car*_*los 14

它对我的原始布尔值不起作用.但它与布尔类型有关.

这是我的属性文件的spring配置声明:

<context:property-placeholder location="classpath:path/to/file/configuracion.properties" />
Run Code Online (Sandbox Code Playgroud)

这是我在属性文件中的内容:

my.property=false
Run Code Online (Sandbox Code Playgroud)

这是我成功的服务类:

...
@Service
public class MyServiceImpl implements MyService{
...
    @Value("${my.property}")
    private Boolean nameOfProperty;
...
Run Code Online (Sandbox Code Playgroud)