Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Neither Spring Boot Actuator + Hal-Browser nor DevTools working

Updated: Attached pom.xml and application.property and some more error / warning msgs.

Hi I am very new to Spring Boot and just taking some classes on Udemy for it.

While following through a class, I create a starter project via spring.io and added actuator and Hal browser dependencies including Dev tools.

Just ran my app and tried to go to localhost:8080/application & /browser as well but I get 404.

What am I doing wrong?

I wrote a simple bean which returns a hard coded value and then print that, I changed the value to test Dev tools and it didn’t restart the resource , I had to kill and restart the app to reflect the new changes ..

How can I check what the issue ?

I can provide console grab if needed.

Please help.

Update: I don't know the significance of the following so putting it in here.

in the XML editor hal is red underlined with the following msg on hover:

The managed version is 3.0.5.RELEASE The artifact is managed in org.springframework.data:spring-data-releasetrain:Kay-SR5

in the XML editor devtools is red underlined with the following msg on hover:

The managed version is 2.0.0.RELEASE The artifact is managed in org.springframework.boot:spring-boot-dependencies:2.0.0.RELEASE

pom.xml:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

    <groupId>com.myoxigen.training.springboot</groupId>
    <artifactId>library</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

    <name>library</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-rest-hal-browser</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

application.properties file:

logging.level.org.springframework = DEBUG
management.security.enabled=false
like image 833
Ankur Saxena Avatar asked Mar 18 '18 15:03

Ankur Saxena


2 Answers

Note: This answer is based on Spring Boot 2 (paths and properties have changed from version 1).

Your pom.xml looks fine to me. To get the "HAL Browser" to work with actuator you should have starters: web, actuator, and Rest Repositories HAL Browser. I recommend Spring Initializr as a nice way to construct an initial valid project structure.

The default path for the actuator is /actuator. Health, for example, is at /actuator/health.

To view the actuator endpoints in the HAL Browser, go to /browser/index.html#/actuator.

You can change the actuator path in application.properties by setting the following.

management.endpoints.web.base-path=/actuator

To run your server, use the following console command:

./mvnw clean spring-boot:run

If you have DevTools in your project, then changes to files in your classpath will restart the server. See my further comments on how to take advantage of DevTools here.


Here's the relevant documentation on a single page for easy searching:

  • https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle
  • https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle
like image 55
Brent Bradburn Avatar answered Sep 28 '22 00:09

Brent Bradburn


Add this Dependency:

    <dependency>
        <groupId>org.springframework.data</groupId>
        <artifactId>spring-data-rest-hal-browser</artifactId>
        <version>3.3.5.RELEASE</version>
    </dependency>`enter code here`

And then go to link:
http://localhost:8080/browser/index.html#
like image 35
Shantesh Sindgi Avatar answered Sep 28 '22 01:09

Shantesh Sindgi