I have a properties XML file as following :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="sample.findAll">
<![CDATA[
The SQL query goes here
]]>
</entry>
</properties>
And a config file as following :
@ImportResource("classpath:sql/find-all-sample-native-query.xml")
@Configuration
public class SampleFindAllConfig {
@Value("#{sample.findAll}")
private String findAllQuery;
@Bean
public String findAllSampleNativeQuery() {
return findAllQuery;
}
}
I'm injecting the Bean in the DAO class as following :
@Inject
private String findAllAnomalieNativeQuery;
But I get this error when I run my application :
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sampleDAO': Unsatisfied dependency expressed through field 'findAllSampleNativeQuery'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sampleFindAllConfig': Unsatisfied dependency expressed through field 'findAllQuery'; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'sample' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext' - maybe not public?
How can I solve this ?