I am starting with spring boot, running a demo spring web starter project, I was checking the spring actuator functionality by calling http://localhost:8080/mappings and http://localhost:8080/health ... It's giving me the "Whitelabel Error Page" ... the log is not showing anything
the project is a very simple boot application created in STS with one @RestController
which is working fine
Main class :
@SpringBootApplication
public class DemoApplication {
public static HashMap<Long,Student> hmStudent;
public static void main(String[] args) {
//dummt code
SpringApplication.run(DemoApplication.class, args);
}
}
Rest Controller :
import java.util.HashMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.example.demo.DemoApplication;
import com.example.demo.entities.Student;
@RestController
@RequestMapping(value="/rest/student")
class StudentService{
@RequestMapping(value="/",method = RequestMethod.GET)
public HashMap<Long,Student> getAllStudents(){
return DemoApplication.hmStudent;
}
.
.
.
.
}
application properties :
spring.datasource.url=jdbc:oracle:thin:@localhost:ibmwas
spring.datasource.username=u
spring.datasource.password=p
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
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.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</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-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jta-atomikos</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</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>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc8</artifactId>
<version>12.0.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
What is the problem and how can I the logs be more descriptive
As of Spring Boot 2.0.0.RELEASE the default prefix for all endpoints is /actuator
So if you want to check the health of an application, you should go to /actuator/health
To make an actuator endpoint available via HTTP, it needs to be both enabled and exposed.
By default:
only the /health
and /info
endpoints are exposed.
all endpoints but /shutdown
are enabled (only /health and /info are exposed)
To expose all endpoints you have to add the following line into application.properties
:
management.endpoints.web.exposure.include=*
I had the same problem. After some trial and error, i got the actuator output when i hit http://localhost:8080 on the browser, it took me to the HAL browser . From the HAL's explorer, i typed actuator, which took me to http://localhost:8080/browser/index.html#http://localhost:8080/actuator and this is where are all the details I was looking for at http://localhost:8080/application was present.
Note Spring boot version that I am using is : 2.0.6 SNAPSHOT.
And, in the application.properties, i had added management.security.enabled=false. w/o this i could see very minimal info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With