Problem: To allow null in @value or to set null as default in Spring @value annotation if the property does not exist.

Solution: after property include :#{null}


// Non null allowed value
String propertyName

// Nullable and null as default value
String propertyName

Explanation: Here we are using Spring Expression Language (SpEL) to set null as default value if does not exist in properties.

Source: documentation

For more interesting tutorials & guides just check them HERE.

Leave a Reply

Your email address will not be published. Required fields are marked *