CdiUnit: DeploymentException: WELD-001408: AppealRepositoryApi 类型与限定符 @Named 的不满意依赖项

问题描述

我正在尝试使用 CdiUnit 测试一些逻辑。

有接口:

 public interface Repository<T extends BaseEntity> {
      T getByReferenceId(UUID referenceUUID);
 }

实现:

 @Named("appealRepository")
 public class RepositoryImpl<T extends BaseEntity> extends AbstractDao<T> implements Repository<T> {
   @Override
   public T getByReferenceId(UUID referenceUUID) {
         return super.getByReferenceId(referenceUUID);
     }
  }

测试类:

 @RunWith(CdiRunner.class)
 public class ReadSourceDataTest {

      @Inject
      @Mock
      @Named("appealRepository")
      private AppealRepositoryApi appealRepository;
     ////
}

Bean 配置是(例如在主块和测试块中):

<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="
  http://xmlns.jcp.org/xml/ns/javaee
  http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
   bean-discovery-mode="all">

运行测试,我收到以下异常:

  DeploymentException: WELD-001408: Unsatisfied dependencies for type Repository with qualifiers @Named

  DeploymentException: WELD-001408: Unsatisfied dependencies for type ConversationContext with qualifiers @Http

在注入点 [BackedAnnotatedField] @Inject @Http private org.jglue.cdiunit.ContextController.conversationContext

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)