【发布时间】:2017-10-01 00:27:32
【问题描述】:
我正在使用 Spring Integration 项目开发 SpringBoot。在升级我的应用程序时,我收到以下错误(仅在关键云上而不是本地) -
在上下文初始化期间遇到异常 - 取消刷新尝试:org.springframework.beans.factory.UnsatisfiedDependencyException:创建名为“cloudDataBaseConfiguration”的bean时出错:通过字段“cloud”表示的依赖关系不满足:创建名为“cloudMultiHttpSecurityConfig”的bean时出错:通过字段'ldapProvider'表示的不满足的依赖关系:创建在类路径资源[com/fidintl/bs/addcash/config/CloudMultiHttpSecurityConfig.class]中定义的名称为'ldapProvider'的bean时出错:通过方法'ldapProvider'参数表示的不满足的依赖关系0:错误创建在类路径资源 [com/fidintl/bs/addcash/config/CloudMultiHttpSecurityConfig.class] 中定义的名称为“iamClient”的 bean:通过方法“iamClient”参数表示的不满足依赖项 0:创建名称为“cloud”的 bean 时出错:请求的 bean当前正在创建:是否存在无法解析的循环引用?嵌套异常是 org.springframework.beans.factory.BeanCurrentlyInCreationException:创建名为“云”的 bean 时出错:当前正在创建请求的 bean:是否存在无法解析的循环引用?嵌套异常是 org.springframework.beans.factory.UnsatisfiedDependencyException:在类路径资源 [com/fidintl/bs/addcash/config/CloudMultiHttpSecurityConfig.class] 中定义名称为“iamClient”的 bean 创建时出错:通过方法“iamClient”表达的依赖关系不满足参数 0:创建名为“云”的 bean 时出错:当前正在创建请求的 bean:是否存在无法解析的循环引用?嵌套异常是 org.springframework.beans.factory.BeanCurrentlyInCreationException:创建名为“云”的 bean 时出错:当前正在创建请求的 bean:是否存在无法解析的循环引用?嵌套异常是 org.springframework.beans.factory.UnsatisfiedDependencyException:在类路径资源 [com/fidintl/bs/addcash/config/CloudMultiHttpSecurityConfig.class] 中定义的名称为“ldapProvider”的 bean 创建时出错:通过方法“ldapProvider”表达的依赖关系不满足参数 0:在类路径资源 [com/fidintl/bs/addcash/config/CloudMultiHttpSecurityConfig.class] 中定义的名称为“iamClient”的创建 bean 时出错:通过方法“iamClient”参数表示的不满足依赖项 0:创建名称为“cloud”的 bean 时出错':请求的 bean 当前正在创建中:是否存在无法解析的循环引用?嵌套异常是 org.springframework.beans.factory.BeanCurrentlyInCreationException:创建名为“云”的 bean 时出错:当前正在创建请求的 bean:是否存在无法解析的循环引用?
我的配置类 -
@Configuration
@EnableWebSecurity
@Order(Ordered.HIGHEST_PRECEDENCE)
@Profile("cloud")
public class CloudMultiHttpSecurityConfig extends WebSecurityConfigurerAdapter {
private static final Logger LOGGER = LoggerFactory.getLogger(CloudMultiHttpSecurityConfig.class);
@Autowired
private AuthenticationProvider ldapProvider;
@Autowired
private Environment env;
@Bean
public Cloud cloud() {
return new CloudFactory().getCloud();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.authenticationProvider(ldapProvider);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().fullyAuthenticated();
http.httpBasic();
http.csrf().disable();
}
@Bean
public AuthenticationProvider ldapProvider(IAMClient iamClient, Cloud cloud) {
IamLdapServiceInfo iamServiceInfo = (IamLdapServiceInfo) cloud.getServiceInfo("ldap-provider-info");
return new AdvLdapAuthProvider(iamServiceInfo, new IAMAuthorityProvider(iamClient));
}
@Bean
public IAMClient iamClient(Cloud cloud) throws Spml2Exception {
WebServiceInfo serviceInfo = (WebServiceInfo) cloud.getServiceInfo("iam-client-info");
IAMClient iamClient = new IAMClient(new Spml2Client(serviceInfo.getUri()), serviceInfo.getAppName(), serviceInfo.getUserName(), serviceInfo.getPassword());
return iamClient;
}
@Bean
public SonUrlService sonataServiceInfo(Cloud cloud) {
LOGGER.info("Inside sonataServiceInfo Bean, type of serviceInfoBean :" + cloud.getServiceInfo("SonUrlService" + env.getProperty("ups_envn")).getClass());
return (SonUrlService) cloud.getServiceInfo("SonUrlService" + env.getProperty("ups_envn"));
}
@Bean
public QueueConnectionFactoryServiceInfo mqServiceInfo(Cloud cloud) {
LOGGER.info("Inside QueueConnectionFactoryServiceInfo Bean, type of mqServiceInfo :" + cloud.getServiceInfo("QueueConnectionFactory_" + env.getProperty("ups_envn")).getClass());
return (QueueConnectionFactoryServiceInfo) cloud.getServiceInfo("QueueConnectionFactory_" + env.getProperty("ups_envn"));
}
@Bean
public QueueNamesServiceInfo queueNamesServiceInfo(Cloud cloud) {
return (QueueNamesServiceInfo) cloud.getServiceInfo("QueueNames_" + env.getProperty("ups_envn"));
}
}
pom.xml -
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
<relativePath />
</parent>
仅当我将其推送到关键云时,此问题才会出现在本地。
【问题讨论】:
标签: spring spring-boot cloud spring-integration cloud-foundry