Spring @Value annotation not using defaults when property is not present

后端 未结 3 2216
失恋的感觉
失恋的感觉 2021-02-07 01:24

I am trying to use @Value annotation in the parameters of a constructor as follows:

@Autowired
public StringEncryptor(
    @Value(\"${encryptor.password:\\\"\\\"         


        
3条回答
  •  臣服心动
    2021-02-07 01:49

    Perhaps initialization of property placeholder configurer fails due to missed properties file, so that placeholders are not resolved. You can configure it to ignore missed files as follows (if you use context namespace to configure it):

    
    

    Also you don't need "..." around default values.

提交回复
热议问题