【发布时间】:2021-07-15 05:34:21
【问题描述】:
我正在将我的 Spring Boot 应用程序从 1.3 升级到 2.1,我能够执行 mvn compile 并构建成功。
但在运行应用程序时出现以下错误
Caused by: java.io.FileNotFoundException: class path resource [config/foo.yml] cannot be opened because it does not exist
我的配置属性类
@Configuration
@PropertySource(value = "classpath:/config/foo.yml", factory = YamlPropertySourceFactory.class)
@ConfigurationProperties(prefix = "config")
public class FooProperties {
private String errorCode;
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
}
foo.yml 仅存在于 src/main/resources/config/foo.yml 下且 yml 文件名正确
foo.yml 内容
config:
name: foo
我看到了很多与相同错误相关的帖子,但对解决此问题没有帮助。
【问题讨论】:
标签: java spring spring-boot