Spring-boot: Question: how to define default null value in application.yml?

Created on 4 Jan 2016  路  6Comments  路  Source: spring-projects/spring-boot

stackoverflow

All 6 comments

The question on Stack Overflow is still open so there's no need for this issue. Thanks.

There is still no answer to this problem on stackoverflow.com, do you have a solution to be able to specify the null value to a property?

ex :
my.property=${null}

You can set to null in porperty file (i don't know yaml) by:

some.property=#{null}

or at java side by:

@Value("${some.property:#{null}}")

https://stackoverflow.com/a/17470732/1386911

You can set to null in porperty file (i don't know yaml) by:
some.property=#{null}

or at java side by:
@value("${some.property:#{null}}")

https://stackoverflow.com/a/17470732/1386911

That doesn't work. Spring doesn't evaluate SpEL in properties files: https://github.com/spring-projects/spring-boot/issues/1672

As far as I can tell, there is no way to specify a null value in application.properties or application.yml (in yaml, that seems to be a bug though, and no by design - see https://jira.spring.io/browse/SPR-15425 )

Hi,
you need to set it like that:

some:
  property: '#{null}'

Hi,
you need to set it like that:

some:
  property: '#{null}'

That's wrong - there will be "#{null}" value in String...

Was this page helpful?
0 / 5 - 0 ratings