测试 Spring Boot Elastic Search 应用程序并在不启动 ES-Instance 的情况下加载上下文

发布于 2025-01-09 00:52:49 字数 344 浏览 1 评论 0原文

由于我更新到 Spring boot 2.5,我的应用程序上下文将无法在测试环境中启动。

我们有几个测试环境。大多数测试不需要 Elastic search 实例。那些需要它的人共享一个 Elasticsearch 测试容器实例。

自更新以来,存储库的创建会导致对 Elasticsearch 进行某种查询。这会失败并导致上下文无法加载。

有没有办法模拟 Spring Data Elasticsearch 部分(不加载并不是加载上下文大部分部分的真正选项)?

我是否应该为所有集成测试启动一个 Elasticsearch 实例(这似乎有点矫枉过正,因为很少有测试真正需要它)?

任何想法都受到高度赞赏。

Since I updated to Spring boot 2.5 my application context won't start in the Test environment.

We have several test environments. Most tests do not need an Elastic search instance. Those that need it share an Elasticsearch test container instance.

Since the Update the creation of repositories causes some kind of query to Elasticsearch. That fails and causes the context not to load.

Is there a way to mock away the Spring Data Elasticsearch part(Not loading is not really an option to load most parts of the context)?

Should I be starting an Elasticsearch Instance for all integration tests(that seems like a little overkill, since few tests actually need it)?

Any ideas are highly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文