jack
jack

Reputation: 273

There was an unexpected error (type=Not Found, status=404)

I looked at many threads here, but no luck

I am new to Spring and working on the Getting started guides on the example Building an Application with Spring Boot

When I execute the below command in the URL box: http://localhost:8080/health

I get this error,

Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Wed Feb 03 13:33:46 CET 2016

There was an unexpected error (type=Not Found, status=404).

No message available

I have made no changes to the code and have also followed the same naming convection.

my 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>org.springframework</groupId>
    <artifactId>gs-spring-boot</artifactId>
    <version>0.1.0</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.3.2.RELEASE</version>
    </parent>

    <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.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <properties>
        <java.version>1.8</java.version>
    </properties>


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

</project>

Please advice. Regards,

Upvotes: 3

Views: 10659

Answers (2)

YunoPaparazzi
YunoPaparazzi

Reputation: 21

Be Careful!!! use devtools! without devtools you will have Whitelabel Error Page and impossible enter to h2 console(If you are using jpa and h2 database for running on localhost) or maybe writing data using SQL in your src/main/resources folder. Try it, hopefully it helps. Even I got stuck at the same problem.

Add dependency in pom.xml and remember always restart the application no matter it's state after making changes in the pom.xml file

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

Upvotes: 0

Dvin
Dvin

Reputation: 149

Make sure that you have the correct package structure in your project. Basically you should locate your main application class in a root package above other classes. At the same time avoid putting the main application in the default package.

Spring documentation suggests the following structure:

com
+- example
 +- myproject
     +- Application.java
     |
     +- domain
     |   +- Customer.java
     |   +- CustomerRepository.java
     |
     +- service
     |   +- CustomerService.java
     |
     +- web
         +- CustomerController.java

Upvotes: 1

Related Questions