Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 316 Vote(s) - 3.46 Average
  • 1
  • 2
  • 3
  • 4
  • 5
This application has no explicit mapping for /error

#11
In my case, this problem occurs when running the SpringApplication from within IntelliJ after running it first with maven.

To solve the problem, I run first `mvn clean`. Then I run SpringApplication from within IntelliJ.
Reply

#12
In my case the controller class was annotated with `@Controller`. Changing that to `@RestController` resolved the problem.
Basically `@RestController` is `@Controller + @ResponseBody`
So either use `@RestController` , or `@Controller` with `@ResponseBody` annotation with each method.

Some useful notes here :

[To see links please register here]

Reply

#13
I too got the same error and was able to resolve the error by adding the below dependency to my pom.xml.

<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>

Reason is we are using JSP as the view. Default embedded servlet container for Spring Boot Starter Web is tomcat.
To enable support for JSP’s, we would need to add a dependency on tomcat-embed-jasper.

In my case I was returning a JSP as view from controller.
Hope this answer helps someone who are struggling with same issue.
Reply

#14
Do maven clean or clean verify and try to run it.The instances has to be cleaned before deploying the another project. It worked for me. I tried it for 2 days to understand this.
Reply

#15
I had tried many ways to fix this problem too, was like, I changed dependency
`<artifactId>spring-boot-starter-web</artifactId>` to `<artifactId>spring-boot-starter-thymeleaf</artifactId>`,
or I replaced annotation @RestController to @Controller but It was the same error. Finally I found a solution by adding a single line of annotation @ComponentScan(basePackages = {"hello"}) on the top of Application class and it works perfectly.

@ComponentScan(basePackages = {"hello"})
public class Application {
public static void main(String[] args) throws Exception {
SpringApplication.run(App.class, args);
}
}

I hope it helps you guys too.
Reply

#16
Make sure your Main.**class** should be on top of your controllers. In case of the following example:

Main.class containing:



@SpringBootApplication
public class Main {
public static void main(String[] args) {
SpringApplication.run(Main.class, args);
}
}

EmployeeController.**class** containing:

@RestController
public class EmployeeController {
@InitBinder
public void setAllowedFields(WebDataBinder dataBinder) {
dataBinder.setDisallowedFields("id");
}

@RequestMapping(value = "/employee/save", method = RequestMethod.GET)
public String save(){
Employee newEmp = new Employee();
newEmp.setAge(25);
newEmp.setFirstName("Pikachu");
newEmp.setId(100);
return "Name: " + newEmp.getFirstName() + ", Age: " + newEmp.getAge() + ", Id = " + newEmp.getId();
}
}


If your main class is in the root folder, just like this path: ***{projectname}/src/main/java/main*** then make sure your controllers below your Main class. For example ***{projectname}/src/main/java/main/controllers***.
Reply

#17
In the main class, after the configuration "@SpringBootApplication", adding "@ComponentScan" without having any arguments, worked for me !!!

Main Class :

@SpringBootApplication
@ComponentScan
public class CommentStoreApplication {

public static void main(String[] args) {
SpringApplication.run(CommentStoreApplication.class, args);

}
}

RestController Class :


@RestController
public class CommentStoreApp {

@RequestMapping("/")
public String hello() {
return "Hello World!";
}
}

P.S: Don't miss to run mvn clean and mvn install commands, before launching the application
Reply

#18
I know it's not exactly answer to question, but this question is first which appears on Google :)

Problem ("This application has no explicit mapping for /error") appears when trying to access Swagger UI.

In my case problems were caused by @RestController("/endpoint"), which isn't handled properly by swagger.

So, this resulted in errors:

@RestController("/endpoint")
public class EndpointController {

And this was fine

@RestController
@RequestMapping("/endpoint")
public class EndpointController {

Reply

#19
In your java file ( say: Viper.java )having main class add: **"@RestController"**
and **@RequestMapping("/")**

@SpringBootApplication
@RestController
public class Viper {

@RequestMapping("/")

public String home(){
return "This is what i was looking for";
}

public static void main( String[] args){

SpringApplication.run(Viper.class , args);
}

}
Reply

#20
Do check if you have marked the controller class with *@RestController* annotation.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through