About spring bean using @Autowired annotation injection failed to issue a non-controller classes - temporary record

E.g:

 A normal Service implementation class as follows:

@Service("taskStatusWarningService")
public class TaskStatusWarningServiceImpl implements ITaskStatusWarningService {

}

In addition implanting in a Service:

@Autowired
    ITaskStatusWarningService taskStatusWarningService;

 

Error when you start the project:

Error creating bean with name 'taskSchedulingServiceBean': Unsatisfied dependency expressed through field 'taskStatusWarningService';
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type 'com.tencent.fit.fdata.console.service.ITaskStatusWarningService'
available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations:
{@org.springframework.beans.factory.annotation.Autowired(required=true)}

 

Solution:

In the spring service.xml file manually injected bean configuration:

<bean id="taskStatusWarningService"
          class="com.tencent.fit.fdata.console.service.impl.TaskStatusWarningServiceImpl">
</bean>

 

other:

This problem is not temporary in-depth understanding of the principles behind until the follow-up have time to understand, related articles first posted at address.

1, on the issue of interdependence inject bean object: https: //blog.csdn.net/w1lgy/article/details/81086171

Guess you like

Origin www.cnblogs.com/bzq-nancy/p/12303771.html