运行时选择spring boot xml配置

发布于 2025-01-19 16:41:09 字数 295 浏览 0 评论 0原文

我必须使用 XML beans 配置运行旧版 spring boot (2.1.8) 应用程序

SpringApplication.run(MyApplication.class, args);

该配置必须在运行时从 src/main 选择/资源目录: a/config.xml 或者 b/config.xml 基于具有相应值 ab 的环境变量。有没有办法像这样加载 XML 配置?

I have to run a legacy spring boot (2.1.8) app

SpringApplication.run(MyApplication.class, args);

with XML beans config which must be selected at runtime from the src/main/resources dir:
a/config.xml
or
b/config.xml
based on an env variable with the respective value a or b. Is there a way to load XML config like this?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

锦上情书 2025-01-26 16:41:09

您是否查看过Spring Profiles?这可能会让你到达你想去的地方。

Have you looked into Spring Profiles; this might get you where you want to be.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文