1
votes

I have the following error, when I try to Autowire my Bean constructor:

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [dimensionmanagement.service.DimensionService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {} at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:920) at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:789) at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:703) at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:795) at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:723) ... 89 more

I have defined the dimensionmanagement.service.DimensionService like that:

@Service @Transactional public class DimensionService implements Serializable {

in my applicationContext.xml :

<context:annotation-config/>
<bean class="org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor"/>
<context:component-scan base-package="dimensionmanagement" />

if any more questions please ask! Thanks Jonas

2
Have you annotated the class that you are trying to Autowire as a Component(@Component) or a similar annotation?? - Satadru Biswas
yes, its annotated as @Component("managementBean") @Scope("session") public class ManagementBean implements Serializable { - jk2
How are you loading your context? Is this a web app? - smp7d
It makes no sense to have a @Transactional @Service bean marked as Serializable. - skaffman

2 Answers

2
votes

You should be autowiring interface and not a class. DimensionService should be an interface. Create a class DimensionServiceImpl by implementing DimensionService

If you want continue using class read here on how to do it.

1
votes

you need

<context:component-scan base-package="com.whatever.mypackage" />