Hi I want to autowire boolean value from properties file have referred following link with maps url Spring properties (property-placeholder) autowiring
but I want to auto wire a boolean property, also have referred question Spring Autowire primitive boolean Spring Autowire primitive boolean but that was for bean value and in my case I want to do the same using property value which is dot separated.
${does.it.allow}
// which fails and gives String cannot be cast to boolean
#{does.it.allow}
// this gives no bean/property defined with name does but I have the correct property file and it proves that container is able to load it because of first error.
It doesn't work for me with primitive boolean. But it does with Boolean type.
This is my spring configuration declaration of the properties file:
<context:property-placeholder location="classpath:path/to/file/configuracion.properties" />
This is what i have in my properties file:
my.property=false
And this is my successful service class:
...
@Service
public class MyServiceImpl implements MyService{
...
@Value("${my.property}")
private Boolean nameOfProperty;
...