【发布时间】:2021-11-08 13:14:52
【问题描述】:
我正在运行 spring boot 2.1.0
我想将我的 db-properties.yml 文件放在我的 webapp 目录之外。
我在我的 tomcat bin 文件夹中创建了一个新的 setenv.sh:
export spring_config_additional-location=/path/to/file/db-properties.yml
我已将文件 db-properties.yml 放在该路径中。
spring:
datasource:
username: username
url: jdbc:oracle:thin:@192.168.122.2:1521:xe
password: password
但我收到此错误:
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
有人可以帮忙吗?
【问题讨论】:
-
你上面显示的不是
.properties是.yml文件 -
感谢您的建议。我已更改为 .yml 并重新启动了 Tomcat,但错误消息仍然相同。请帮忙。谢谢。
-
您应该导出
SPRING_CONFIG_ADDITIONALLOCATION,它是文件的路径还是完整路径?如果它只是没有文件名的路径,除非您指示 Spring Boot 加载名为`db-properties` 和application的文件,否则它将不会加载任何内容。 -
我也试过输入文件名,但错误信息还是一样。
-
这能回答你的问题吗? Don't work spring.config.additional-location
标签: spring-boot tomcat