【发布时间】:2020-08-31 12:52:33
【问题描述】:
我们有一个 maven 项目,它在 src/main/resource 文件夹下只有 yaml 文件和相关的文本文件。我们将其打包为 Jar 文件。结构如下:
src\main\resource
application-configone.yml
application-configtwo.yml
license.txt
application-configone.yml 文件包含 license.txt 文件的条目
license
path: src\main\resource\license.txt
现在我们将这个 Jar 工件导入另一个 Web 应用程序。在 web 应用程序的 yml 文件中,我们将 yml 文件从 Jar 导入为
spring.active.profile = configone, configtwo
我们遇到的问题是 Web 应用程序无法启动,因为它无法读取/获取 application-configone 文件中定义的 license.txt 文件。
我们如何读取/访问打包在 web 应用程序中的 jar 中的 license.txt 文件
【问题讨论】:
-
嗨,有趣,不确定这是否会引起兴趣stackoverflow.com/questions/36768656/…
-
@IronMan:感谢您的链接,但我们不想在我们打包为 jar 的项目中有任何类文件,它的目标是只保存配置文件。恐怕在共享链接无济于事。
-
所以你只有这个jar里面的主类?
-
没有主类,只有 yml 文件
标签: java spring spring-boot