CDI-不满足类型 QueueSession 的依赖关系
CDI-Unsatisfied dependencies for type QueueSession
我正在尝试编写注解来注入 JMS 资源。这是我的代码
public class JMSResourceProducer {
private static final String WL_INIT_CONN_FACTORY ="weblogic.jndi.WLInitialContextFactory";
private String WL_SERVER_URL = "URL";
private String QF ="QFNAME";
private String QQ ="QNAME";
public InitialContext createInitialContext() throws NamingException {
Hashtable properties = new Hashtable();
properties.put(Context.INITIAL_CONTEXT_FACTORY, WL_INIT_CONN_FACTORY);
properties.put(Context.PROVIDER_URL, WL_SERVER_URL);
return new InitialContext(properties);
}
@Produces @Image2000
public QueueSession createQueueSession () throws NamingException, JMSException {
InitialContext initialContext = createInitialContext();
QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) initialContext.lookup(QF);
QueueConnection queueConnection = queueConnectionFactory.createQueueConnection();
return queueConnection.createQueueSession(true, 0);
}
@Produces @Image2000
public Queue createQueue ( ) throws NamingException {
InitialContext initialContext = createInitialContext();
Queue queue = (Queue)initialContext.lookup(QQ);
return queue;
}
}
这就是我在 class
中使用它的方式
@Inject @Image2000
private QueueSession queueSession;
@Inject @Image2000
private Queue jmsQueue;
我的批注
@Qualifier
@Target({TYPE, METHOD, PARAMETER, FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Image2000 {
}
但是当我的 Wildfly 启动时我遇到了以下错误..
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type QueueSession with qualifiers @Image2000
在注入点 [UnbackedAnnotatedField] @Inject @Image2000 .queueSession
知道我的制作人有什么问题吗class?
根据 beans.xml 中定义的发现模式,您可能需要使用 bean 定义注释(Dependent、ApplicationScoped 或其他更适合的注释)来注释 JMSResourceProducer。
我正在尝试编写注解来注入 JMS 资源。这是我的代码
public class JMSResourceProducer {
private static final String WL_INIT_CONN_FACTORY ="weblogic.jndi.WLInitialContextFactory";
private String WL_SERVER_URL = "URL";
private String QF ="QFNAME";
private String QQ ="QNAME";
public InitialContext createInitialContext() throws NamingException {
Hashtable properties = new Hashtable();
properties.put(Context.INITIAL_CONTEXT_FACTORY, WL_INIT_CONN_FACTORY);
properties.put(Context.PROVIDER_URL, WL_SERVER_URL);
return new InitialContext(properties);
}
@Produces @Image2000
public QueueSession createQueueSession () throws NamingException, JMSException {
InitialContext initialContext = createInitialContext();
QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) initialContext.lookup(QF);
QueueConnection queueConnection = queueConnectionFactory.createQueueConnection();
return queueConnection.createQueueSession(true, 0);
}
@Produces @Image2000
public Queue createQueue ( ) throws NamingException {
InitialContext initialContext = createInitialContext();
Queue queue = (Queue)initialContext.lookup(QQ);
return queue;
}
}
这就是我在 class
中使用它的方式@Inject @Image2000
private QueueSession queueSession;
@Inject @Image2000
private Queue jmsQueue;
我的批注
@Qualifier
@Target({TYPE, METHOD, PARAMETER, FIELD})
@Retention(RetentionPolicy.RUNTIME)
public @interface Image2000 {
}
但是当我的 Wildfly 启动时我遇到了以下错误..
Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type QueueSession with qualifiers @Image2000
在注入点 [UnbackedAnnotatedField] @Inject @Image2000 .queueSession
知道我的制作人有什么问题吗class?
根据 beans.xml 中定义的发现模式,您可能需要使用 bean 定义注释(Dependent、ApplicationScoped 或其他更适合的注释)来注释 JMSResourceProducer。