Spring @Value default value
This article shows how to provide a default value for the @Value annotation. In the below code, if the property.name doesn’t exist in the application properties or environment, defaultValue will be assigned to the propertyName field. SimpleComponent.java import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; @Component public class SimpleComponent { @Value("${property.name:defaultValue}") private String propertyName; // getters, setters, etc } …