读取来自Internet上的.properties文件的属性。

发布于 2025-02-04 02:27:16 字数 641 浏览 2 评论 0 原文

我在 Internet/Online 上有一个.properties文件(您可以说这是一个外部文件)。我想从中读取属性(版本),以更新我的.xml文件中的模块版本。 我搜索了 propertyplaceholderholderconfigurer ,但它被贬低了。还有其他方法吗?

属性文件:

github.dd-core=6.5.2

xml文件:

<modules>
  <module>
      <name>dd-core-6.5.2</name>
      <artifactid>com.dd-core</artifactid>
      <version>6.5.2</version>
  </module>
</modules>

预期结果:in 版本标签,而不是 6.5.2 我想使用属性 github.dd核在运行时/动态更新版本。谢谢。

I have one .properties file present on the internet/online (you can say it's an external file). I want to read the properties (versions) from it to update the modules' versions in my .XML file.
I searched about the PropertyPlaceholderConfigurer, but it is deprecated. Is there any other way for this?

Properties file:

github.dd-core=6.5.2

XML file:

<modules>
  <module>
      <name>dd-core-6.5.2</name>
      <artifactid>com.dd-core</artifactid>
      <version>6.5.2</version>
  </module>
</modules>

Expected Result: In version tag, instead of 6.5.2 I want to use property github.dd-core to update the version at runtime/dynamically. Thank you.

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

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

发布评论

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

评论(1

孤云独去闲 2025-02-11 02:27:16

您是否尝试过这里提供的解决方案? propertyPlacePlaceHolderholderConfigurer替代方案

否则,您也许可以研究属性插件,声称可以做类似的事情: https://www.mojojohaus.org/properties-maven-maven-maven-plugin-plugin-plugin/index.htmll

从文件或URL加载的属性可用于在不同的环境中以不同的方式过滤资源。 那些使用Spring PropertyPlaceHolderConfigurer 的人可以看到这些目标如何有用。请注意,URL格式接受Spring's class Path:style pseudo-url语法。

具体:

read-project-properties目标读取属性文件和URL,并将属性存储为项目属性。它是指定pom.xml中属性的替代方案。当在构建时间可用的运行时资源中定义属性时,它特别有用。

Did you try the solutions offered here? PropertyPlaceHolderConfigurer Alternative

Otherwise you can perhaps look into the properties plugin, it claims to do a similar thing: https://www.mojohaus.org/properties-maven-plugin/index.html

The properties loaded from files or URLs can be used to filter resources differently for different environments. Those using Spring's PropertyPlaceholderConfigurer can see how these goals can be useful. Note that the URL format accepts Spring's classpath: style pseudo-URL syntax.

Specifically: https://www.mojohaus.org/properties-maven-plugin/read-project-properties-mojo.html

The read-project-properties goal reads property files and URLs and stores the properties as project properties. It serves as an alternate to specifying properties in pom.xml. It is especially useful when making properties defined in a runtime resource available at build time.

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