2.4. 运行 Spring Boot 应用程序
您可以在两个步骤中,将 HawtIO 附加到 Spring Boot 应用程序。
流程
将
io.hawt:hawtio-springboot和支持的 Camel Spring Boot starters 添加到pom.xml中的依赖项中:<dependencyManagement> <dependencies> <dependency> <groupId>io.hawt</groupId> <artifactId>hawtio-bom</artifactId> <version>4.1.0.redhat-00015</version> <type>pom</type> <scope>import</scope> </dependency> <!-- ... other BOMs or dependencies ... --> </dependencies> </dependencyManagement> <dependencies> <dependency> <groupId>io.hawt</groupId> <artifactId>hawtio-springboot</artifactId> </dependency> <!-- Mandatory for enabling Camel management via JMX / HawtIO --> <dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-management-starter</artifactId> </dependency> <!-- (Optional) Required for HawtIO Camel route diagram tab --> <dependency> <groupId>org.apache.camel.springboot</groupId> <artifactId>camel-spring-boot-xml-starter</artifactId> </dependency> <!-- ... other dependencies ... --> </dependencies>通过将以下行添加到
application.properties来启用 HawtIO 和 Jolokia 端点:spring.jmx.enabled = true management.endpoints.web.exposure.include = hawtio,jolokia在开发模式下运行带有 Spring Boot 应用程序的 HawtIO,如下所示:
mvn spring-boot:run- 打开 http://localhost:8080/actuator/hawtio 以查看 HawtIO 控制台。
2.4.1. 配置 HawtIO 路径 复制链接链接已复制到粘贴板!
复制链接链接已复制到粘贴板!
如果您不更喜欢 HawtIO 端点的 /actuator 基础路径,您也可以执行以下操作:
使用
management.endpoints.web.base-path属性自定义 Spring Boot 管理基础路径:management.endpoints.web.base-path = /您还可以通过设置
management.endpoints.web.path-mapping.hawtio属性来自定义 HawtIO 端点的路径:management.endpoints.web.path-mapping.hawtio = hawtio/consoleExample:
- 有一个可正常工作的 Spring Boot 示例,它演示了如何监控 Web 应用来公开有关 Apache Camel 路由、指标等信息,使用 HawtIO Spring Boot 示例。
-
用于实时值和图表的 MBean 是
java.lang/OperatingSystem。尝试查看 Camel 路由。请注意,当您在树中更改选择时,可以根据内容动态更改可用选项卡列表。