小编Jim*_*imo的帖子

我可以在 Spring Boot 应用程序中使用 xml 属性文件而不是 application.properties 吗?

在我们的Spring Boot应用程序中,我们使用application.properties,但运营团队要求使用基于 XML 的属性文件。格式很简单。如果apllication.properties看起来像:

com.mail.host=mail_host
db.connection.port=1521
Run Code Online (Sandbox Code Playgroud)

相应的 xml 应该是:

<XML>
    <com>
        <mail>
            <host>
                mail_host
            </host>
        </mail>
    </com>
    <db>
        <connection>
            <port>
                1521
            </port>
        </connection>
    </db>
</XML>
Run Code Online (Sandbox Code Playgroud)

我们实现了它,但Spring Boot仍在寻找application.properties以获取其特定属性。这有点不方便。我们希望将所有属性放在一个地方,即 - XML 文件。

覆盖Spring Boot的默认行为以使其在 XML 文件中查找属性的最佳方法是什么?(当然,它需要一些自定义代码,因为Spring Boot理解简单的属性格式(如key=value)和 YAML 格式,但不理解XML。)

xml properties spring-boot

4
推荐指数
2
解决办法
3528
查看次数

标签 统计

properties ×1

spring-boot ×1

xml ×1