SPRING MVC - 自动装配的 bean 出错

SPRING MVC - Error with autowired beans

我有这个 maven 项目及其模块

Parent

|_____Model

|_____Persistence

|_____Service

         |_ service-context.xml

|_____View

         |_ spring/app-config.xml

我有这个控制器 controllers.HomeController 在视图模块中

@Controller

public class HomeController {

protected final Log logger = LogFactory.getLog(getClass());

private IServicioService servicioService;

@RequestMapping(value="/home.htm")
public ModelAndView handleRequest(HttpServletRequest request,  HttpServletResponse response)
        throws ServletException, IOException {

    logger.info("Returning hello view");

    return new ModelAndView("home.jsp");
}

@Autowired
public void setServicioService(IServicioService servicioService) {
    this.servicioService = servicioService;
}

还有我的服务servicios.ServicioService在服务模块

@Service
public class ServicioService implements IServicioService{

private ServicioDao servicioDao;

public ServicioService(){}

/*************************** Gett&Sett ****************************/

public ServicioDao getServicioDao() {
    return servicioDao;
}

public void setServicioDao(ServicioDao servicioDao) {
    this.servicioDao = servicioDao;
}

}

IServicioService 没有@Service ServicioService bean 在 service-context.xml 中这样定义

<bean id="servicioService" class="servicios.ServicioService">
    <property name="servicioDao"   ref="servicioDao" />
</bean>

** 我的 app-config.xml 正在导入 service-context.xml **

   <import resource="classpath*:service-context.xml" />
   <context:component-scan base-package="controllers" />

不知道为什么给我这个

没有为依赖项找到 [servicios.ServicioService] 类型的匹配 bean:预计至少有 1 个 bean 有资格作为此依赖项的自动装配候选者。依赖注解:{}

求助!!

您的问题可能出在 xml 配置中。 尝试在您的 app-config.xml 行中添加:

<context:component-scan base-package="servicios" />

之后你应该对你的 daos 做同样的事情