user1022900
user1022900

Reputation: 13

Spring won't detect the autowired field

I'm declaring the <context:component-scan base-package="com.blah.domain.*" /> to scan for all the annotations in spring. i have declared my class under the same package

package com.blah.domain;

@Service
public class UserService extends BaseService implements InitializingBean {
  .....
}

The BaseService definition is as follow:-

@Service
public class BaseService {
  ........
}

I tried invoking the UserService through the web application as well as test case, but in both the cases, the exception is as follows

org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.blah.domain.service.UserService

I'm pasting the spring definition below:

<task:annotation-driven />
<context:annotation-config/>
<context:component-scan base-package="com.blah.domain.service.*" />

Upvotes: 1

Views: 242

Answers (1)

skaffman
skaffman

Reputation: 403501

The base-package attribute takes a package name, not a wildcard, i.e. it should be

<context:component-scan base-package="com.blah.domain" />

Upvotes: 4

Related Questions