The recent Hawtio 2.3.0 release added support for Spring Boot 2. What follows is a demonstration of how to embed Hawtio into your Spring Boot applications.
Assuming you have an existing Spring Boot application, simply add the
Hawtio runs as a Spring Boot management endpoint. Therefore, we need to enable it along with Jolokia in the application configuration.
To keep things simple, we’ll also disable Hawtio authentication.
Or if you prefer YAML.
Now run the application.
Open a browser to http://localhost:8080/actuator/hawtio and you should see the Hawtio web console.
Hawtio Spring Boot Plugin
The Hawtio Spring Boot plugin provides functionality to interact with some of the Spring Boot actuator endpoints via JMX.
Displays the current health status of the application together with details returned from any Spring Boot health checks.
Lists all of the available loggers in the application. You can modify the level of a logger and the changes will take effect immediately.
Lists any HTTP traces for your application and lets you view information about the request / response such as headers, time taken etc.
There are a few ways to customize Hawtio on Spring Boot.
Custom Hawtio Endpoint Path
You can use some of the following properties to customize the Hawtio endpoint path.
Customize Jolokia Access
By placing a jolokia-access.xml file in
src/main/resources you can add restrictions on how hosts interact with the Jolokia endpoint.
Spring Boot 1 Support
If you need support for Spring Boot 1, the setup process is mostly identical. The hawtio-springboot dependency should be changed to hawtio-springboot-1.
Some of the Spring Boot configuration property names will be different. Refer to the Spring Boot 1 documentation for more information.
The Hawtio project has some example Spring Boot applications which demonstrate how to configure authentication and how to integrate with other frameworks like Apache Camel.
Hopefully this was a good introduction of how Spring Boot integration works in Hawtio. If you have feedback, we’d love to hear about it! Feel free to open an issue or raise a pull request if you’d like to contribute.