wangyuheng / spring-boot-sample

MIT License
14 stars 4 forks source link

springboot-endpoint ,无法升级使用springboot2 #2

Open sxm20074428 opened 6 years ago

wangyuheng commented 6 years ago

springboot2加强了actuator功能,通过annotation+配置即可暴露对应的endpoint。 e.g.

@Component
@Endpoint(id = "properties")
public class PropertiesAction {

    @ReadOperation
    public Object loadAllProperties() {
        try {
            return PropertiesLoaderUtils.loadAllProperties("application.properties");
        } catch (IOException e) {
            return "read application fail! error: " + e.getMessage();
        }
    }

}
management.server.port=9527
management.server.address=localhost
management.endpoints.web.base-path=/endpoint
management.endpoints.web.exposure.include=*
curl http://localhost:9527/endpoint/properties