I have strange error on attempt to inject int primitive via Spring @Value annotation.
I have property file "myProps.properties" with property
number.of.search.log.events.in.queue=4
Configuration class on scanned path with content
@Configuration
@ComponentScan(basePackages = {
"com.search.log"
})
@PropertySource("classpath:applicationConfig.properties")
@EnableAspectJAutoProxy
public class SearchLogConfiguration {
}Aspect where primitive should be injected
@Aspect
@Component
public class SearchLogAspectHandler {
@Value("${number.of.search.log.events.in.queue:2}")
public int numberOfSearchLogEventsInQueue;
...
}
Every time on application start I got this exception:
Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: public int numberOfSearchLogEventsInQueue; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [int] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Value(value=${number.of.search.log.events.in.queue})}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:298)
Question: Please, help to find out why Spring can't inject primitive, but instead is trying to inject bean of type [int] and can't found one.
Aucun commentaire:
Enregistrer un commentaire