spring-projects / spring-boot

Spring Boot
https://spring.io/projects/spring-boot
Apache License 2.0
74.93k stars 40.63k forks source link

Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Wed May 31 23:17:56 IST 2017 There was an unexpected error (type=Not Found, status=404). #9371

Closed nitinpawar283 closed 7 years ago

nitinpawar283 commented 7 years ago
wilkinsona commented 7 years ago

Given the lack of description, I'm guessing this was opened in error.

Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Wed May 31 23:17:56 IST 2017 There was an unexpected error (type=Not Found, status=404).

This is the default content of a 404 response when a page isn't found for the request's URL.

Arrsoya commented 7 years ago

make sure you are requestiong the right URl. For example if in your Restcontroller you have defined this : @RequestMapping("/") public String index() { return "Greetings from Spring Boot!"; }

your URL must be like "http://localhost:8080/" because of the @RequestMapping("/")

I hope this was helpful

varun-vijayarao commented 6 years ago

ive got the same error. i'm trying to display a greeting on my localhost. the codes are greetingcontroller: package com.example.Mydemo;

import java.util.concurrent.atomic.AtomicLong;

import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam;

public class GreetingController {

private static final String template = "Hello, %s!";
private final AtomicLong counter = new AtomicLong();

@RequestMapping("/greeting")
public Greeting greeting(@RequestParam(value="name", defaultValue="World") String name) {
    return new Greeting(counter.incrementAndGet(),
                        String.format(template, name));
}

}

greeting: package com.example.Mydemo;

public class Greeting {

    private final long id;
    private final String content;

    public Greeting(long id, String content) {
        this.id = id;
        this.content = content;
    }

    public long getId() {
        return id;
    }

    public String getContent() {
        return content;
    }
}

my pom is

      <?xml version="1.0" encoding="UTF-8"?>

-

4.0.0 com.example Mydemo 0.0.1-SNAPSHOT jar Mydemo Demo project for Spring Boot

-

org.springframework.boot spring-boot-starter-parent 1.5.9.RELEASE

-

UTF-8 UTF-8 1.8 - - org.springframework.boot spring-boot-starter-web - org.springframework.boot spring-boot-starter-test test - - - org.springframework.boot spring-boot-maven-plugin
snicoll commented 6 years ago

@varun-vijayarao we don't use the tracker for questions. Please ask on StackOverflow or join us on Gitter.

ghost commented 5 years ago

make sure we have to specify the package where SpringApplication.run(DemoApplication.class, args) available.Then it is working fine

kvh44 commented 5 years ago

I have found the problem. When you execute the generated jar file of spring boot. You need to execute the command out of the folder target like this

" mvn clean package && java -jar target/mmm-0.0.1-SNAPSHOT.jar".

Otherwise it can't find the folder WEB-INF which located in "/src/main/webapp/".

wilkinsona commented 5 years ago

@kvh44 Thanks for trying to help, but if you are building a jar file you shouldn't be using src/main/webapp. There's a note about this in the documentation:

Do not use the src/main/webapp directory if your application is packaged as a jar. Although this directory is a common standard, it works only with war packaging, and it is silently ignored by most build tools if you generate a jar.

BynuLorenz commented 5 years ago

@kvh44 Thank you for your solution. took me days to figure it out. Any suggetion why application can't find WEB-INF which located in "/src/main/webapp/" while running on IDE.

davidecherubini commented 4 years ago

@kvh44 I'm new to programming and I encountered the same problem mentioned above, when I run the application via SpringBoot. Where should I write that line out of the destination?

jmdopereiro commented 4 years ago

I got this problem running from the IDE in the examples of https://spring.io/guides/tutorials/spring-security-and-angular-js

Alpiniatechnologies commented 3 years ago

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

Wed Aug 04 21:50:06 IST 2021 There was an unexpected error (type=Not Found, status=404).

this my error please solve

snicoll commented 3 years ago

@Alpiniatechnologies please ask questions on StackOverflow.

pankajkumarsingh123 commented 1 year ago

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

Tue Aug 01 10:38:46 IST 2023 There was an unexpected error (type=Not Found, status=404). No message available