Spring @Value annotated method, use default value when properties not available

To answer your question exactly...

@Value("${secret:secret}")
private String ldapSecret;

And a few more variations are below for completeness of the examples...

Default a String to null:

@Value("${secret:#{null}}")
private String secret;

Default a number:

@Value("${someNumber:0}")
private int someNumber;

Just use:

@Value("${secret:default-secret-value}")
private String ldapSecret;