Spring data gemfire 通过方法';会议区域';
我的gradle.build的正确依赖关系快让我发疯了 为了访问Apache Geode 1.10服务器,我使用:Spring data gemfire 通过方法';会议区域';,spring-data-gemfire,spring-boot-data-geode,Spring Data Gemfire,Spring Boot Data Geode,我的gradle.build的正确依赖关系快让我发疯了 为了访问Apache Geode 1.10服务器,我使用: // Geode client dependency implementation 'org.springframework.geode:spring-geode-starter:1.2.13.RELEASE' implementation 'org.springframework.data:spring-data-geode:2.2.12.RELEASE' implem
// Geode client dependency
implementation 'org.springframework.geode:spring-geode-starter:1.2.13.RELEASE'
implementation 'org.springframework.data:spring-data-geode:2.2.12.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-tomcat:2.2.13.RELEASE'
此操作失败,错误如下:
org.springframework.context.support.AbstractApplicationContext 596 refresh:
Exception encountered during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'ClusteredSpringSessions' defined in class path resource
[org/springframework/session/data/gemfire/config/annotation/web/http/GemFireHttpSessionConfiguration.class]:
Unsatisfied dependency expressed through method 'sessionRegion' parameter 0;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.springframework.data.gemfire.config.annotation.ClientCacheConfiguration':
Initialization of bean failed; nested exception is java.lang.IllegalAccessError:
class org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration$$Lambda$703/0x0000000801025d10
tried to access protected method 'boolean org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport.hasValue(java.lang.Number)'
(org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration$$Lambda$703/0x0000000801025d10
and org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport are in unnamed module of loader 'app')
对于“ClusteredSpringSessions”
的未满足的PendencyException
缺少依赖项,有什么可以告诉我
如果我删除@enablegmfirehttpsession
注释,那么我会得到错误
2021-02-02T19:29:49,011 WARN [main] org.springframework.context.support.AbstractApplicationContext 596 refresh:
Exception encountered during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'cacheManager' defined in class path resource [org/springframework/data/gemfire/cache/config/GemfireCachingConfiguration.class]:
Unsatisfied dependency expressed through method 'cacheManager' parameter 0;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.springframework.data.gemfire.config.annotation.ClientCacheConfiguration':
Initialization of bean failed; nested exception is java.lang.IllegalAccessError:
class org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration$$Lambda$679/0x00000008010306b8
tried to access protected method 'boolean org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport.hasValue(java.lang.Number)'
(org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration$$Lambda$679/0x00000008010306b8
and org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport are in unnamed module of loader 'app')
对于'cacheManager'
,有什么可以告诉我未满足的pendencyException
缺少依赖项
谢谢
更新应用程序的运行方式类似,但更具体
@SpringBootApplication
@ComponentScan({"api", "rsocket", "pricing", "listeners", "dealing", "web"}) // scans packages for @ components
@EnableLogging(logLevel="debug", logFile="geodeApi.log")
public class Api {
private static final Logger log = LogManager.getLogger(Api.class);
public static void main(String[] args) {
log.info("In Main");
SpringApplication app = new SpringApplication(Api.class);
app.setWebApplicationType(WebApplicationType.REACTIVE);
SpringApplication.run(Api.class, args);
log.info("Out Main");
}
}
例如,组件扫描可以找到各种@component
注释类
@Component
@EnableClusterDefinedRegions(clientRegionShortcut=ClientRegionShortcut.PROXY)
public class ClientCache {
private static final Logger log = LogManager.getLogger(ClientCache.class);
@Resource
private Region<String, String> admin;
@Autowired
LQuote lQuote;
@Autowired
LReject lReject;
@Autowired
LDeal lDeal;
@Autowired
DealNumber dealNumber;
@Autowired
PriceService priceService;
@PreDestroy
public void onDestroy() throws Exception {
log.info("onDestroy");
String guid = UUID.randomUUID().toString().substring(0, 8).toUpperCase();
admin.put(guid, "API Shutdown");
// TODO: Cancel all open quote streams
log.traceExit();
}
@Bean
ApplicationRunner StartedUp(){
log.traceEntry("StartedUp");
return args -> {
String guid = UUID.randomUUID().toString().substring(0, 8).toUpperCase();
admin.put(guid, "API Started");
lQuote.addListener();
lReject.addListener();
lDeal.addListener();
// Get latest deal number
int currentId = dealNumber.readCurrentId();
// Set it + 1 in case the web server was reboot on the fly
priceService.setCurrentId(currentId + 1);
log.traceExit();
};
}
@组件
@EnableClusterDefinedRegions(clientRegionShortcut=clientRegionShortcut.PROXY)
公共类ClientCache{
私有静态最终记录器log=LogManager.getLogger(ClientCache.class);
@资源
私人区域管理;
@自动连线
LQuote LQuote;
@自动连线
LReject LReject;
@自动连线
LDeal-LDeal;
@自动连线
DealNumber DealNumber;
@自动连线
价格服务价格服务;
@发情前期
public void ondestory()引发异常{
日志信息(“onDestroy”);
字符串guid=UUID.randomUUID().toString().substring(0,8).toUpperCase();
admin.put(guid,“API关闭”);
//TODO:取消所有打开的报价流
log.traceExit();
}
@豆子
ApplicationRunner已启动(){
日志跟踪(“启动”);
返回args->{
字符串guid=UUID.randomUUID().toString().substring(0,8).toUpperCase();
admin.put(guid,“API已启动”);
lQuote.addListener();
lReject.addListener();
lDeal.addListener();
//获取最新交易编号
int currentId=dealNumber.readCurrentId();
//将其设置为+1,以防web服务器动态重新启动
priceService.setCurrentId(currentId+1);
log.traceExit();
};
}
从技术上讲,没有必要明确声明SDG依赖项
SBDG依赖项(即org.springframework.geode:spring-geode-starter
)已经包括SDG(org.springframework.data:spring-data-geode
)。您可以从开始到最后跟踪依赖项跟踪
根据SBDG的规定,SBDG1.2.13.版本
特别包括SDG2.2.12.版本
(已经),从技术上讲是Apache Geode1.9.2
但是,如果您需要使用Apache Geode1.10
,那么您可以(建议)简单地声明依赖关系管理,以强制在Gradle构建中使用Apache Geode1.10
:
plugins {
id 'org.springframework.boot' version '2.2.13.RELEASE'
id 'io.spring.dependency-management' version '1.0.10.RELEASE'
id 'java'
}
dependencyManagement {
dependencies {
dependency 'org.apache.geode:geode-core:1.10.0'
dependency 'org.apache.geode:geode-cq:1.10.0'
dependency 'org.apache.geode:geode-lucene:1.10.0'
dependency 'org.apache.geode:geode-wan:1.10.0'
}
}
dependencies {
implementation 'org.springframework.geode:spring-geode-starter:1.2.13.RELEASE`
implementation 'org.springframework.boot:spring-boot-starter-tomcat'
}
...
警告:SDG2.2.12.发布版
正式基于ApacheGeode1.9.2
,尽管它应该与ApacheGeode1.10
配合使用,但在某些用例中可能会存在一些限制
当然,Spring Initializer现在使用新的SBDG BOM,这使得管理单个SBDG模块依赖项变得更加容易,这与Spring Boot的依赖项管理如何管理可传递的依赖项(包括第三方LIB)没有什么不同
关于例外情况
事实上,在我看来,您确实遇到了配置问题,而不是依赖性问题
当然,很难说清楚,因为您共享了非常小的Gradle构建配置,并且没有来自Spring Boot应用程序配置的代码片段,只提到了异常消息以及我能够从异常消息中派生出什么。因此,现在,我将根据您提供的以及我知道或能够派生的内容继续
查看(第一个)异常消息的这一部分:
具体而言:
Unsatisfied dependency expressed through method 'sessionRegion' parameter 0
Initialization of bean failed; nested exception is java.lang.IllegalAccessError:
tried to access protected method 'boolean org.springframework.data.gemfire
.config.annotation.support.AbstractAnnotationConfigSupport
.hasValue(java.lang.Number)'
此消息指的是SSDG和SBDG提供的(Spring Java)
“未满足的依赖项”或“参数0”是SSDG中声明的sessionRegion(..)
(基于Spring JavaConfig的)@Bean
定义方法中的第一个方法参数。它是创建“ClusteredSpringSessions”所需的GemFire缓存实例的依赖项(例如ClientCache
)区域
现在的问题是,缓存是如何创建的
好的,这就是框架下一步要做的…解析缓存bean依赖项(实例引用),这需要首先触发缓存创建(由于依赖项顺序)
我们看到出现了一个IllegalAccessError
错误(O.O),这对我来说已经是一个版本问题了,但是
ClientCacheConfiguration
由SDG提供
最后,我们得出了根本原因
class org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration$$Lambda$703/0x0000000801025d10
tried to access protected method 'boolean org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport.hasValue(java.lang.Number)'
注意:ClientCacheConfiguration
AbstractCacheConfiguration
,它支持abstractAnnotationConfig
,因此应该可以“访问”受保护的hasValue(:Number)
方法
主线程似乎位于使用AbstractAnnotationConfig.hasValue(:Number)
方法的某个位置
我不完全确定这意味着什么
org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration$$Lambda$703/0x0000000801025d10
and org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport are in unnamed module of loader 'app'
您是否偶然使用了SpringBoot的新(分层)Docker映像支持
第二条异常消息(这次涉及cacheManager
bean)导致的结果实际上是相同的。它没有什么不同,只是涉及另一个bean(即cacheManager
bean),缓存实例上的:
Error creating bean with name 'cacheManager' defined in class path resource
[org/springframework/data/gemfire/cache/config/GemfireCachingConfiguration.class]
: Unsatisfied dependency expressed through method 'cacheManager' parameter 0;
nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'org.springframework.data.gemfire.config.annotation.ClientCacheConfiguration':
Initialization of bean failed; nested exception is java.lang.IllegalAccessError:
class org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration$$Lambda$679/0x00000008010306b8
tried to access protected method 'boolean org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport.hasValue(java.lang.Number)'
(org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration$$Lambda$679/0x00000008010306b8
and org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport are in unnamed module of loader 'app')
具体而言:
Unsatisfied dependency expressed through method 'sessionRegion' parameter 0
Initialization of bean failed; nested exception is java.lang.IllegalAccessError:
tried to access protected method 'boolean org.springframework.data.gemfire
.config.annotation.support.AbstractAnnotationConfigSupport
.hasValue(java.lang.Number)'
以及:
我不熟悉这个错误消息(基本上说,类“在unn中)
(org.springframework.data.gemfire.config.annotation.AbstractCacheConfiguration$$Lambda$679/0x00000008010306b8
and org.springframework.data.gemfire.config.annotation.support.AbstractAnnotationConfigSupport
are in unnamed module of loader 'app')
// Geode client dependency
implementation 'org.springframework.geode:spring-geode-starter:1.2.8.RELEASE'
implementation 'org.springframework.data:spring-data-geode:2.2.8.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-tomcat'