Obtenir une erreur, je ne sais pas pourquoi puisque j'utilise beans.xml
dans les deux modules affectés.Dépendances insatisfaites pour le type Chaîne Jboss6
WELD-001408 dépendances non satisfaites pour le type [chaîne] avec des qualificatifs [@SystemProperty] au point d'injection [paramètre [1] [constructeur] @Inject com.comp.alert.EmailAlertHandler publique (String, String)]
SystemProperty.java:
@Qualifier
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.PARAMETER, ElementType.FIELD, ElementType.METHOD, ElementType.TYPE})
public @interface SystemProperty {
@Nonbinding String value();
}
EmailAlertHandler.java (seulement inclus une partie du code qui utilise @Systemproperty:
@Email
@Stateless
public class EmailAlertHandler implements AlertHandler {
@Inject
public EmailAlertHandler(@SystemProperty("min.email.from") String emailFrom,
@SystemProperty("min.email.to") String emailTo) {
this.emailFrom = emailFrom;
this.emailTo = emailTo;
}
@Override
public void sendAlert(Alert alert) {
//body omitted
}
}
beans.xml qui est défini dans le module de EmailAlertHandler:
<?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 qui est DÉFINIES dans le module pour 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 est injecté ici. La méthode sendAlertAsync appelé dans une autre classe pour lancer essentiellement de la fonctionnalité:
@Singleton
@Startup
public class AlertManager {
@Inject @Email
private AlertHandler emailAlertHandler;
@Asynchronous
public void sendAlertAsync(Alert alert) {
// Handle alert via email
emailAlertHandler.sendAlert(alert);
}
}
Essentiellement toutes les solutions que je l'ai déjà trouvé sur les erreurs de dépendances non satisfaites/manquantes similaires pointer à la configuration beans.xml mais qui n'a rien résolu.