gpt4 book ai didi

java - 将 application.properties 与 tomcat 容器的 .war 分开

转载 作者:行者123 更新时间:2023-11-28 22:06:06 25 4
gpt4 key购买 nike

当我使用可执行文件时 .jar对于我的项目,我可以把我的 application.properties文件与我的 .jar 相同的文件夹中,我所有的属性值将从扩展 application.properties 中读取文件。

我的问题是: .war 可以这样制作和 tomcat服务器?

[更新]

答案是: 在独立的 tomcat 上,您必须将 application.properties<tomcat>/bin

感谢@Strelok

最佳答案

您可以运行您的应用程序,将 spring.config.location 属性设置为使用 file: 协议(protocol)的属性文件的路径:

# will look for /etc/myapp/application.properties
-Dspring.config.location=file:/etc/myapp/

# will look for /etc/myapp/custom.properties
-Dspring.config.location=file:/etc/myapp/custom.properties

始终搜索的默认配置位置:

  1. 文件:./config/
  2. 文件:./
  3. 类路径:/config/
  4. 类路径:/

Externalized Configuration 中有更多信息Spring Boot 文档的一部分。

关于java - 将 application.properties 与 tomcat 容器的 .war 分开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45830010/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com