- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 Spring Boot 应用程序,配置了 Pivotal GemFire ClientCache
实例及其相应的域对象。我还使用 Spring Boot Test 进行单元测试。对于每个测试用例执行,无论是通过类还是 Maven 构建,如果 GemFire 缓存关闭,Spring ApplicationContext
将无法加载。
如何在不依赖GemFire缓存的情况下启动Spring Boot应用程序?
最佳答案
我不确定我是否完全理解您的意思...
"For every test case execution, either through class or Maven build, Spring
ApplicationContext
fails to load if the GemFire cache is down."
您是否正在重新创建 ClientCache
测试类中每个测试用例(方法)的实例?
如果是这样,那么这可能会很棘手,因为即使在调用 ClientCache.close()
之后也是如此。 ,GemFire可能还没有完全“关闭”并释放了ClientCache
使用的所有资源。实例。然而,通常这并不能阻止 Spring ApplicationContext
以免在后续测试用例执行时重新创建。它通常只会导致随后的测试失败,因为 ClientCache
实例是脏的或过时的,保留上一个(或最后一个)测试用例执行的旧状态。
你是否也在使用Spring的@DirtiesContext
也在你的测试用例方法上吗?
通常,明智的做法是循环使用 ApplicationContext
每个测试类都有 GemFire 缓存实例(例如 ClientCache
),其中测试类中的每个测试用例方法将使用相同的 ApplicationContext
和ClientCache
实例;这是最理想的。
因此,我有两件事要与您分享:
首先,看看新的 Spring Boot for Apache Geode/Pivotal GemFire项目。文档是here 。我announced该项目已近一个月前推出。该项目采用“客户端”视角,使用 Pivotal GemFire 构建 Spring Boot 应用程序。也就是说,它给你一个自动配置的 ClientCache
默认实例。
具体来说,请查看 Pivotal GemFire 的 Spring Boot 测试套件,从 here 开始。几乎所有这些测试类都使用 ClientCache
实例并测试 Pivotal GemFire 的各个方面,例如 CQ 或安全性等。
在某些测试类中,我使用了“模拟”ClientCache
实例(例如,这个 test class ,特别是这个 test configuration )。然而,在许多其他情况下,我使用了实时 GemFire ClientCache
例如,对于 example或者这个test class ,这很有趣,因为这个测试类甚至 launches a server对于ClientCache
要连接到的实例(测试本身)。
Spring Boot for Apache Geode/Pivotal GemFire 中的所有测试协调逻辑均由另一个新项目 Spring Test for Apache Geode/Pivotal GemFire 提供。 。不幸的是,Apache Geode/Pivotal GemFire 的 Spring Test 很大程度上仍处于 WIP 阶段,因此还没有文档。不过,我广泛使用这个新的测试项目来测试 Apache Geode/Pivotal GemFire 的 Spring Boot。您将在扩展类中看到它的存在,例如 ForkingClientServerIntegrationTestsSupport
等等。
总之,使用新的 Spring Boot for Pivotal GemFire 和 Spring Test for Pivotal GemFire 项目作为编写更有效的单元和集成测试的指南。
最后,如果您有一个重现您问题的 GitHub 存储库示例,我可以帮助您指出正确的方向。
希望这有帮助!
问候,约翰
关于java - 如何在不依赖 Pivotal GemFire 缓存的情况下启动 Spring Boot 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51510520/
我正在将 GemFire 集群从 8.2.7(使用 Spring Data GemFire 1.6.0.RELEASE)迁移到 Pivotal GemFire 9.3.0(SDG 2.0.7.RELE
我正在尝试按日期查询我的 gemfire 区域。任何人都可以帮助解决如何格式化 to_date 以便对我的 gemfire 区域进行日期查询。 我有一个格式为 'MM/dd/yyyy' 的日期,然后我
我想在 Spring Boot 应用程序中创建一个 Gemfire 区域。按照这个 sample ,它在不添加数据库支持的情况下运行良好。如果我添加数据库,它会显示错误,如“创建名称为‘dataSou
我正在尝试使用 Spring Data GemFire 和 Spring Boot 连接到现有的 GemFire 定位器。 以下是我的缓存配置 当我尝试运行此代码时
我正在尝试使用 Spring Data GemFire 和 Spring Boot 连接到现有的 GemFire 定位器。 以下是我的缓存配置 当我尝试运行此代码时
我的团队使用 Geode 作为临时分析引擎。我们在 Geode 中存储了大量原始数据对象(每个 200MB+),但这些对象永远不会直接返回给客户端。相反,我们严重依赖自定义函数执行来在 Geode 内
我一直在研究“内存数据网格”,并看到了“gemfire”一词。我很困惑。似乎 gemfire 是一个术语,指的是像数据库一样存储和操作数据但在计算机内存中的技术,不是吗? gemfire到底是什么?
我正在为一个 Java 应用程序编写设计文档,其中两个冗余进程从消息队列中读取项目,我们希望它们都使用相同的 key 将项目存储到 gemfire 存储中,目的是许多运行连续查询的应用程序会处理这些项
我正在尝试在 springXD 中设置流。 gemfire 安装在 10.99.40.60 机器上,springXD 安装在我的本地 VM 上。 xd:>stream create -
我有一个客户端/服务器拓扑场景。 在本地运行由一个定位器和两台服务器组成的简单集群,不同的 JVM 进程,服务器在启动时没有使用以下配置创建区域: ${gemfire.server.na
我正在尝试使用 gfsh 启动定位器,但我不断发现找不到主类。 我正在运行这个:gfsh start locator --name=locator1 此后我收到以下错误: Error: Could n
我正在与 GemFire 合作开展一个项目。为了将数据从数据库导入到 GemFire,我做了一个连接到数据库和 GemFire 的 java 程序,然后我从数据库中选择数据并放入它位于 GemFire
我试图在一个 JVM 中创建一个本地缓存和一个客户端缓存,但是我收到下面所述的错误,我认为这是由于缓存是单例而发生的,并且每个 JVM 只能创建一个。 有没有人知道一个好的解决方法? 错误: Erro
我正在使用 gemfire,目前有一个客户端和一个服务器。现在,服务器动态地在一个区域中创建一些子区域,并在其中放置一些对象。我正在尝试使用客户端检索对象,但看不到对象或子区域。如何同步区域?我还能做
我有一个嵌入到具有本地 Gemfire 缓存的 Web 服务中的 JAR。我试图解决的问题是这些数据的过期。 我创建了一个自定义过期计时器,它将设置每个条目的过期时间(以秒为单位),并绑定(bind)
在此gemfire tutorial 我无法解释这个通用声明: people = cache.createRegionFactory(REPLICATE) .addCacheListene
我使用 gemfire 作为我的缓存。缓存堆大小远高于 100GB。我发现当我们从客户端将数据放入gemfire缓存中时,它会序列化数据并发送给服务器,并且在服务器上数据以序列化形式存储。问题: 当我
我们使用 Pivotal Gemfire 作为数据缓存。最近,我们从 gemfire 8.2.1 迁移到 9.5.1,具有完全相同的区域、数据和索引。但是在特定的一个区域上创建索引花费了太多时间,该区
当我在 gfsh 控制台中运行 SELECT 查询时,它按预期工作: query --query="SELECT * FROM /channelProfiles_composite_asrd WHER
我已经为我的用例搜索了解决方案,但没有找到正确的解决方案,因此期待一些好的想法可以进一步探索。 我有两个 gemfire(版本 8.2)集群(私有(private)和公共(public)),每个集群都
我是一名优秀的程序员,十分优秀!