![](/img/trans.png)
[英]Issue with org.springframework.beans.factory.UnsatisfiedDependencyException:
[英]...factory.UnsatisfiedDependencyException actually of type 'org.springframework.cloud.sleuth.instrument.messaging.LazyTopicConnectionFactory'
所以我一直在努力尋找解決這個問題的方法! 任何見解都會有所幫助!
我收到以下錯誤
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'routerConnectionFactory' defined in class path resource [com/CONFIDENTIAL/event/processor/configuration/EventsConfiguration.class]: Unsatisfied dependency expressed through method 'routerConnectionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'actionRouterConnectionFactory' is expected to be of type 'org.apache.activemq.ActiveMQConnectionFactory' but was actually of type 'org.springframework.cloud.sleuth.instrument.messaging.LazyTopicConnectionFactory'
代碼片段
@Bean(name = "routerConnectionFactory")
@Primary
public CachingConnectionFactory routerConnectionFactory(ActiveMQConnectionFactory actionRouterConnectionFactory ){
CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory();
cachingConnectionFactory.setTargetConnectionFactory(actionRouterConnectionFactory);
return cachingConnectionFactory;
}
@Bean
public ActiveMQConnectionFactory actionRouterConnectionFactory(
@Value("${confidential.gateway.message.broker.url}") String brokerURL,
@Value("${confidential.router.message.broker.user.name}") String userName,
@Value("${confidential.router.message.broker.user.password}") String password,
@Value("true") Boolean alwaysSyncSend, RedeliveryPolicy defaultEntry,
@Value("${shared.amq.keystore.path:#{null}}") String keyStorePath,
@Value("${shared.amq.keystore.password:#{null}}") String keyStorePassword) throws Exception {
ActiveMQSslConnectionFactory targetConnectionFactory= new ActiveMQSslConnectionFactory();
targetConnectionFactory.setBrokerURL(brokerURL);
targetConnectionFactory.setUserName(userName);
targetConnectionFactory.setPassword(password);
if(!StringUtils.isEmpty(keyStorePath) && !StringUtils.isEmpty(keyStorePassword)){
targetConnectionFactory.setTrustStore(keyStorePath);
targetConnectionFactory.setTrustStorePassword(keyStorePassword);
}
targetConnectionFactory.setAlwaysSyncSend(alwaysSyncSend);
targetConnectionFactory.setRedeliveryPolicy(defaultEntry);
return targetConnectionFactory;
}
spring-cloud-sleuth-core : 2.2.6.RELEASE
spring-cloud-sleuth-zipkin : 2.2.6.RELEASE
active-mq-broker, active-mq-camel, client, jms-pool , open-wire-legacy, pool, spring : 5.15.13
other spring boot and related dependencies : 2.2.6.RELEASE
參考了有關此問題的多篇文章(也在 StackoverFlow 上),還嘗試禁用 sleuth 但沒有幫助!
有什么線索嗎?
您的方法簽名正在尋找與 ActiveMQ 緊密耦合的“ActiveMQConnectionFactory”。 最有可能的是,意圖是耦合到 JMS API。 更改代碼以改用 javax.jms.ConnectionFactory。 (ActiveMQConnectionFactory 實現 javax.jms.ConnectionFactory)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.