Spring 引导执行器样本不工作

Spring boot actuator sample not working

我检查了 spring-boot 项目来自:

https://github.com/spring-projects/spring-boot

和 运行ning spring-boot-sample-actuator 之后 mvn spring-boot:运行 并导航到 http://localhost:8080/info

我明白了:

{version: "@project.version@", artifact: "@project.artifactId@", group: "@project.groupId@", name: "@project.name@"}

似乎 使用 Maven 自动 属性 扩展(也在这里解释 http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#production-ready-application-info-automatic-expansion) 不管用。

我错过了什么,如何让它发挥作用?

事情是 spring-boot-maven-plugin 首先尝试能够使开发人员富有成效。 简而言之,当 path/file 同时存在于 target/classes 和源或资源中(例如 application.properties)时,它将删除内容在 target/classes 下。 这是clearly visible here.

因为它正在删除 target/classes/application.properties,并将项目资源添加到类路径(因此在此处添加 src/main/resources/application.properties), 只能得到未过滤的文件

幸运的是,您可以通过将此标志添加到命令行来禁用此行为:

-Drun.addResources=false

或者在POM插件配置中

<addResources>false</addResources>