Correctness6 - SpotBugsExtensionForSpringFrameWork/CS5098 GitHub Wiki
Summary: Property in placeholder should be defined (BeanDefinitionStoreException)
Description
Could Not Resolve Placeholder - assummed that 'some.property' is not defined.
... value="${some.property}" ... // error
------------------------------------------------
@Value("${some.property}") // error
private String someProperty;
Solution
// define a property
some.property=someValue
Theory
In addition to using SpEL, Environment interface also can be used to get properties. However, in actual development, the Environment interface is rarely used directly. So, the placeholder in SpEL is mostly selected. (196 pages)
In order for Spring's Environment inside the ApplicationContext interface to read properties, the context:property-placeholder tag must be used in a configuration file (XML or Java annotation). (Pro Spring 5 - 197 page) With this, Spring can check the location of the property file and read the property value. If the property value does not exist, a BeanDefinitionStoreException error will occur.
Implement strategy (maybe algorithm)
- Check the properties that the application use. There should be using one form of configuration between XML and Java annotation.
- Get the property value and check if the SpEL are correctly using a value among the values in the property files.
Reference List
https://www.baeldung.com/spring-beandefinitionstoreexception https://www.baeldung.com/properties-with-spring Pro Spring 5