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代碼的一部分:
在所述模塊中定義爲EmailAlertHandlerbeans.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但是這並沒有解決任何事情。