【发布时间】:2018-10-27 23:45:31
【问题描述】:
这是我的项目结构
- src
- main
- java
- mypackage
- resources
- config
application.yml
我在 application.yml 中有这个
document:
templates:
filetypes:
- elem1
- elem2
- elem3
- elem4
hello:
test: "hello"
在我的端点中,我有以下内容
@Value("${document.templates.filetypes}")
List<String> templatesFileTypes;
@Value("${document.hello.test}")
String hello;
在任何功能中,我都可以访问System.out.println(hello) 之类的东西,而且它工作得很好
但对于文件类型,它甚至没有编译,我收到这个错误:
创建名为“configurationEndPoint”的 bean 时出错:注入 自动装配依赖失败;嵌套异常是 java.lang.IllegalArgumentException:无法解析占位符 'document.templates.filetypes' 的值 "${document.templates.filetypes}"
搜索了很多,我能找到的每个解决方案都是指向写入 application.yml/application.xml 文件,这在我的情况下是无效的,因为我可以读取其他测试字符串但不能读取数组;
我试过String[] 我试过ArrayList<String> 但我无法让它工作
【问题讨论】:
-
@JoshSullivan 不
标签: java spring spring-boot