Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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,

like image 432
jack Avatar asked Feb 01 '26 09:02

jack


1 Answers

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
like image 189
Dvin Avatar answered Feb 03 '26 23:02

Dvin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!