①在POM文件中添加相關引用
<!-- actuator監控信息完善 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <!-- 這里可以根據自己的需要,修改匹配規則 --> <build> <finalName>${project.artifactId}</finalName> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <configuration> <delimiters> <delimit>$</delimit> </delimiters> </configuration> </plugin> </plugins> </build>
②在屬性文件添加
info.app.name=amber-cloud-dept-8001
info.company.name=www.amber.com
info.build.artifactId=$project.artifactId$
info.build.version=$project.version$
注:如果是YML,則需要做相應的格式調整,如有問題可以把其中$符號可以更換成@試試。
③補充
management.endpoints.web.exposure.include=*,hystrix.stream
再訪問/actuator/info即可
④Endpoint的一些有用的特征
Endpoint ID | Description |
---|---|
auditevents | 顯示應用暴露的審計事件 (比如認證進入、訂單失敗) |
info | 顯示應用的基本信息 |
health | 顯示應用的健康狀態 |
metrics | 顯示應用多樣的度量信息 |
loggers | 顯示和修改配置的loggers |
logfile | 返回log file中的內容(如果logging.file或者logging.path被設置) |
httptrace | 顯示HTTP足跡,最近100個HTTP request/repsponse |
env | 顯示當前的環境特性 |
flyway | 顯示數據庫遷移路徑的詳細信息 |
liquidbase | 顯示Liquibase 數據庫遷移的纖細信息 |
shutdown | 讓你逐步關閉應用 |
mappings | 顯示所有的@RequestMapping路徑 |
scheduledtasks | 顯示應用中的調度任務 |
threaddump | 執行一個線程dump |
heapdump | 返回一個GZip壓縮的JVM堆dump |