我在使用不同模块之间共享的CDI制作人时遇到了一些麻烦。 我们的想法是在模块Common.jar中声明生产者:
@Qualifier
@Retention(RUNTIME)
@Target({ TYPE, METHOD, FIELD, PARAMETER })
public @interface Property {
@Nonbinding
String value() default "";
@Nonbinding
boolean required() default true;
}
并且:
@ApplicationScoped
public class PropertyProducer implements Serializable {
@Property
@Produces
public String produceString(final InjectionPoint ip) {
return "needed string";
}
并在model.jar的另一个模块中使用它:
@Inject
@Property("model.needed.string")
private String neededString;
此结果在运行时出现以下异常:
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type String with qualifiers @Default
at injection point [BackedAnnotatedField] @Inject private neededString
WELD-001475: The following beans match by type, but none have matching qualifiers:
- Producer Method [String] with qualifiers [@BatchProperty @Any] declared as [[UnbackedAnnotatedMethod] @Produces @BatchProperty public org.jberet.creation.BatchBeanProducer.getString(InjectionPoint)]
结构如下: project structure
有什么想法吗?
谢谢。