java - NoSuchBeanDefinition 由于通过构造函数参数 0 表示的不满足依赖关系
问题描述
我使用标记为@Provider 的库 X 的类(JAX-RS 的注释)。
我想扩展 X 的功能,所以我扩展了这个类:
@Provider
public class WrappedX extends ContainerRequestFilter,
ContainerResponseFilter {
private final X objectX;
public WrappedX (X objectX) { this.objectX = objectX; } }
@Override
<Some function1>
@Override
<Some function2>
}
在另一个文件中,我创建 WrappedX Spring Configuration 类:
@Configuration
public class WrappedXConfig {
@Bean
public WrappedX getWrappedXFilter(){
X objectX = new XBuilder().build();
return new WrappedX(objectX);
}
}
当我运行它时,我得到了错误:
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'getWrappedXFilter' defined in file
[<path>/WrappedX.class]:
Unsatisfied dependency expressed through constructor argument with index 0 of type [org.company.package1.X]: : No qualifying bean of
type [org.company.package1.X] found for dependency:
expected at least 1 bean which qualifies
as autowire candidate for this dependency.
Dependency annotations: {}; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type [org.company.package1.X] found
for dependency: expected at least 1 bean
which qualifies as autowire candidate for this dependency.
Dependency annotations: {}
我看到另一段代码与我所做的完全一样。但他们运行他们的代码就好了。有人可以解释这里发生了什么吗?
解决方案
推荐阅读
- swift - 当 nil 应该返回特定的默认值时,在函数参数中使用可选项的最简洁方法是什么?
- c++ - C ++中的十六进制与十进制
- ckeditor - 添加自定义标题以上传图像
- php - Yii2 在所有 js 文件末尾注册 Asset Files (js)
- python - 配置 pip 命令行参数
- android - 未显示 Android 免安装应用权限请求对话框
- tensorflow - Tensorflows tf.layers.dense 是否会使输入尺寸变平?
- apache - 如何使用 Apache 拒绝所有文件?
- android - 在 RelativeLayout 中并排放置两个视图的格式问题
- apache-spark - spark setCassandraConf 没有按预期工作