如何使用 spring data elastcsearch 和 maven 打包 spring boot 项目而不跳过测试?

发布于 2025-01-18 19:58:33 字数 514 浏览 3 评论 0原文

我正在整理一个使用Spring Boot Elasticsearch的Spring Boot Project,该计划是在我的本地计算机上打包该项目作为.jar文件,将其发送到我的异地服务器并运行它。

在我的服务器上,Elasticsearch设置为仅通过Local Network的IP地址接受连接(即Curl Localhost:9200无法正常工作,但Curl 172.168.0.7:9200确实可以使用),我无法在本地计算机上访问。

当我运行该项目时,我将YML文件中的Elasticsearch URI设置为Localhost,并且效果很好。但是,当我尝试用Maven打包该项目时,它会运行测试,然后连接到172.168.0.7:9200,当然会失败,使我获得了失败的消息,例如无法连接到该地址。

解决方法是设置Maven以跳过Altogehter测试,但这似乎并不是正确的方法。

我该怎么办,可以通过测试打包项目?

做了一些研究,其中大多数是关于单位测试的,但是就我而言,我没有写任何测试课,没有确定的速度,我只是陷入了包装过程中。

I'm putting together a spring boot project that uses spring boot elasticsearch, the plan is to package the project on my local machine as a .jar file, send it to my offsite server, and run it.

On my server, elasticsearch is set to accept connections via local network's ip addresses only (i.e. curl localhost:9200 won't work but curl 172.168.0.7:9200 does), which i'm not able to access on my local machine.

When i run the project, i set the elasticsearch uris in my yml files to localhost, and it works fine. But when i try to package the project with maven, it runs test, which then connects to 172.168.0.7:9200 and of course fails, leaving me with a failed message like can't connect to that address.

The workaround is to set maven to skip tests altogehter, but that does't seem to be the right way to do it.

What should i do so that i can package the project with test?

Did a little research and most of them were about unit test, but in my case i didn't write any test classes, don't have surefire, i'm just stuck in the process of packaging.

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

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

发布评论

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