Java 春之豆
在Spring3.2项目中,我在启动应用程序时遇到问题。 系统似乎无法识别某些bean 我得到这个错误:Java 春之豆,java,spring,spring-mvc,Java,Spring,Spring Mvc,在Spring3.2项目中,我在启动应用程序时遇到问题。 系统似乎无法识别某些bean 我得到这个错误: 27-May-2014 12:41:05.879 SEVERE [http-nio-8084-exec-5] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class org.spring
27-May-2014 12:41:05.879 SEVERE [http-nio-8084-exec-5] org.apache.catalina.core.StandardContext.listenerStart Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'reportResource': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.prjx.domain.ReportFacade com.prjx.web.resources.ReportResource.reportFacade; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.prjx.domain.facade.ReportFacade] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
@Controller
public class ReportResource
{
@Autowired
private UserFacade userFacade;
@Autowired
private ReportFacade reportFacade;
...
}
@Component
public interface ReportFacade{
...
}
public class ReportFacadeImpl implements ReportFacade
{
...
}
在application-context.xml中,我有
<context:component-scan base-package="com.prjx" />
如何解决此问题?您尚未为ReportFacade接口定义实现 春天不是魔法。它无法读懂你的大脑来知道豆子应该做什么
因此,您需要创建ReportFacade接口的实现,将其放入Spring扫描的包中,并使用
@Component
对该实现进行注释。接口本身不应该有@组件注释。您还没有为ReportFacade接口定义实现
@Component
public interface ReportFacade{
...
}
春天不是魔法。它无法读懂你的大脑来知道豆子应该做什么
因此,您需要创建ReportFacade接口的实现,将其放入Spring扫描的包中,并使用@Component
对该实现进行注释。接口本身不应该有@组件注释。您还没有为ReportFacade接口定义实现
@Component
public interface ReportFacade{
...
}
春天不是魔法。它无法读懂你的大脑来知道豆子应该做什么
因此,您需要创建ReportFacade接口的实现,将其放入Spring扫描的包中,并使用@Component
对该实现进行注释。接口本身不应该有@组件注释。您还没有为ReportFacade接口定义实现
@Component
public interface ReportFacade{
...
}
春天不是魔法。它无法读懂你的大脑来知道豆子应该做什么
因此,您需要创建ReportFacade接口的实现,将其放入Spring扫描的包中,并使用@Component
对该实现进行注释。接口本身不应该有@组件
注释
@Component
public interface ReportFacade{
...
}
无法注入依赖项,因为它是一个接口
所以做下面的事情
public interface ReportFacade{
...
}
@Component
public class ReportFacadeImpl implements ReportFacade{
...
}
然后
将注入其实现者ReportFacadeImpl
确保spring配置文件中的componentscan具有正确的接口和类的包条目
无法注入依赖项,因为它是一个接口
所以做下面的事情
public interface ReportFacade{
...
}
@Component
public class ReportFacadeImpl implements ReportFacade{
...
}
然后
将注入其实现者ReportFacadeImpl
确保spring配置文件中的componentscan具有正确的接口和类的包条目
无法注入依赖项,因为它是一个接口
所以做下面的事情
public interface ReportFacade{
...
}
@Component
public class ReportFacadeImpl implements ReportFacade{
...
}
然后
将注入其实现者ReportFacadeImpl
确保spring配置文件中的componentscan具有正确的接口和类的包条目
无法注入依赖项,因为它是一个接口
所以做下面的事情
public interface ReportFacade{
...
}
@Component
public class ReportFacadeImpl implements ReportFacade{
...
}
然后
将注入其实现者ReportFacadeImpl
确保spring配置文件中的componentscan包含正确的接口和类的包条目。您必须在类实现接口上使用@Component,而不是在接口上。.请参阅我在那里解释的答案。.您必须在类实现接口上使用@Component,而不是在接口上。.请参阅我解释的答案那里..你必须在类实现接口上使用@Component,而不是在接口上..看我在那里解释的答案..你必须在类实现接口上使用@Component,而不是在接口上..看我在那里解释的答案。。