放置在类路径根目录中(src/main/resources)。
正确使用同一个地方的application.properties文件。
这是代码:
@Controller
@EnableAutoConfiguration
public class TestResource {
@RequestMapping("/")
public @ResponseBody Map<String, String> test() {
return Collections.singletonMap("text", "test text");
}
public static void main(String[] args) {
SpringApplication.run(TestResource.class, args);
}
}
最佳答案
您需要添加对 snakeyaml 的依赖。示例 Maven 依赖项:
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.13</version>
</dependency>
关于spring-boot 自动配置忽略 application.yml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21004467/