How to correctly specify a default value in the Spring @Value annotation?

Try with $ as follows:

@Value("${props.isFPL:true}")
private boolean isFPL=false;

Also make sure you set the ignore-resource-no-found to true so that if the property file is missing, the default value will be taken.

Place the following in the context file if using XML based configuration:

<context:property-placeholder ignore-resource-not-found="true"/>

If using Java configurations:

 @Bean
 public static PropertySourcesPlaceholderConfigurer   propertySourcesPlaceholderConfigurer() {
     PropertySourcesPlaceholderConfigurer p =  new PropertySourcesPlaceholderConfigurer();
     p.setIgnoreResourceNotFound(true);

    return p;
 }

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)