2017-07-31 62 views
1

获取错误,不确定为什么因为我在两个模块中都使用了beans.xml字符串类型Jboss6的不满意依赖关系

WELD-001408类型不合格依赖[字符串]与限定符[@SystemProperty]在注射点[的[参数1] [构造] @注入公共com.comp.alert.EmailAlertHandler(字符串,字符串)]

SystemProperty.java:

@Qualifier 
@Retention(RetentionPolicy.RUNTIME) 
@Target({ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD, ElementType.TYPE}) 
public @interface SystemProperty { 

    @Nonbinding String value(); 

} 

EmailAlertHandler.java(只包括使用@Systemproperty代码的一部分:

在所述模块中定义为EmailAlertHandler

beans.xml中:

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://java.sun.com/xml/ns/javaee" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation=" 
     http://java.sun.com/xml/ns/javaee 
     http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"/> 

beans.xml中在所述模块中definied为SystemProperty:

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://java.sun.com/xml/ns/javaee" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation=" 
     http://java.sun.com/xml/ns/javaee 
     http://java.sun.com/xml/ns/javaee/beans_1_0.xsd"/> 

EmailAlertHandler这里注入。被称为该sendAlertAsync方法,另一类基本上揭开序幕的功能:

@Singleton 
@Startup 
public class AlertManager { 

    @Inject @Email 
    private AlertHandler emailAlertHandler; 

    @Asynchronous 
    public void sendAlertAsync(Alert alert) { 
     // Handle alert via email 
     emailAlertHandler.sendAlert(alert); 
    } 

} 

基本上所有的解决方案,我已经在类似的不满/丢失的依赖发现错误指向配置的beans.xml但是这并没有解决任何事情。

回答

1

它看起来没有产生这些字符串。

你有生产者吗?

你可以尝试使用:

public class PropertyProducer { 

    @Produces 
    public String createProperty(InjectionPoint injectionPoint) { 
     String value =injectionPoint.getAnnotation(SystemProperty.class).value(); 
     return System.getProperty(value); 
    } 
} 
相关问题