【发布时间】:2017-07-20 17:30:11
【问题描述】:
我正在使用带有 gemfire 8.2 的 springboot 1.5.2 并在 xml 中配置主机和端口运行良好。相反,我们硬编码需要从云服务器配置中读取的主机和端口的值,并且它无法在 xml 中读取这些值。计划将主机和端口设置从 xml 移动到 java 代码。启动时出现以下错误。
现有的 XML 配置
<gfe:pool id="clientPool" subscription-enabled="true">
<gfe:locator host="x.x.x.x" port="x" />
</gfe:pool>
在spring启动时导入了这个xml。
XML 到 Java 代码
@Configuration
public class GeodeConfig {
@Resource
GemFireCache gemfireCache;
@Bean
ClientCacheFactoryBean gemfireCache() {
ClientCacheFactoryBean gemfireCache = new ClientCacheFactoryBean();
gemfireCache.setClose(true);
gemfireCache.setCacheXml(new ClassPathResource("gemfirexml.xml"));
return gemfireCache;
}
@Bean
PoolFactoryBean gemfirePool(
@Value("${host}") String host,
@Value("${port}") int port) {
PoolFactoryBean gemfirePool = new PoolFactoryBean();
gemfirePool.setName("clientPool");
gemfirePool.setSubscriptionEnabled(true);
gemfirePool.setThreadLocalConnections(false);
gemfirePool.setServers(Collections.singletonList(new ConnectionEndpoint(host, port)));
return gemfirePool;
}
}
例外
Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-07-20 12:17:51.486 ERROR [magenta-enterprise-event-testing,,,] 22640 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'geodeConfig': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'gemfireCache': FactoryBean threw exception on object creation; nested exception is com.gemstone.gemfire.cache.CacheXmlException: Unknown XML element "beans"
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:321) ~[spring-context-4.3.7.RELEASE.jar:4.3.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264) ~[sprin
【问题讨论】:
标签: gemfile cloud-foundry spring-data-gemfire