Rule java:S6804: "@Value" annotation should inject property or SpEL expression
gives a false positive for @Value
on Resource
. This rule was added with [SONARJAVA-4643] - Jira in Sonar Java version 7.27.0.33463.
This code is valid and should not produce a warning, but Sonar incorrectly flags it:
public class TestComponent {
@Value("classpath:some.xml")
private Resource someXml;
}
See https://www.baeldung.com/spring-load-resource-as-string#using-spel