Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用组件扫描(spring)时出现问题-不注入依赖项_Spring_Dependency Injection_Component Scan - Fatal编程技术网

使用组件扫描(spring)时出现问题-不注入依赖项

使用组件扫描(spring)时出现问题-不注入依赖项,spring,dependency-injection,component-scan,Spring,Dependency Injection,Component Scan,我正在开始一个新的应用程序开发,我收到了一些代码(原型)。我注意到spring-servlet.xml使用了以下标记: 如果您使用@Autowired注释,请确保bean由spring容器初始化。您可以通过创建bean,或者只向context:component scan标记提供包名,以说明Spring必须扫描包搜索构造型注释,并在应用程序上下文中注册bean。在文章中: 我发现使用命令启动的建议如下: standalone.sh -Dorg.jboss.as.logging.per-deplo

我正在开始一个新的应用程序开发,我收到了一些代码(原型)。我注意到spring-servlet.xml使用了以下标记:


如果您使用@Autowired注释,请确保bean由spring容器初始化。您可以通过
创建bean,或者只向context:component scan标记提供包名,以说明Spring必须扫描包搜索构造型注释,并在应用程序上下文中注册bean。

在文章中:

我发现使用命令启动的建议如下:

standalone.sh -Dorg.jboss.as.logging.per-deployment=false
@Autowired @Qualifier("studentSearchDaoImpl") 
private StudentSearchDao studentSearchDao;
这样做,我可以看到真正的原因:

Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not
 autowire field: private packages.StudentSearchDao packages.studentSearchDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException
: No qualifying bean of type [packages.StudentSearchDao] 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)}
因此,我在@Autowired之后添加了“@Qualifier”,如下所示:

standalone.sh -Dorg.jboss.as.logging.per-deployment=false
@Autowired @Qualifier("studentSearchDaoImpl") 
private StudentSearchDao studentSearchDao;

你需要向我们展示你得到的错误,好的观点和。。。刚刚加上。。。很抱歉。你也可以发布你的
web.xml
吗?刚刚添加了Geoand。谢谢我懂了。谢谢你帮助我。实际上,bean没有初始化。我现在发布了服务器日志。。。不确定它是否与警告相关:JBAS011054:找不到类org.springframework.web.context.request.async.StandardServletAsyncWebRequest的默认构造函数试图找出这意味着什么以及如何修复它。。。