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

#1
I used maven to do the tutorial

[To see links please register here]

All the codes I used was copied.

The Application can run, but I get the error:


>Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Jun 30 17:24:02 CST 2015 There was an unexpected error (type=Not Found, status=404).
No message available

How can I fix it?

Reply

#2
The tutorial expects you to have the Thymeleaf template engine in classpath. I ran into the same problem and finally figured this out. I'll reach out to the tutorial author to include that info.

The easiest way if you've followed the tutorial is to add the dependency to your pom.xml in the project root folder. Next time you run your app Spring will detect Thymeleaf and use the uploadform template

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

For the full example see their [Github repository][1].


[1]:

[To see links please register here]

Reply

#3
The problem is that you are navigating to localhost:8080/ instead of localhost:8080/upload as prescribed in the guide. Spring Boot has a default error page used when you navigate to an undefined route to avoid giving away server specific details (which can be viewed as a security risk).

You're options are to either: visit the right page, add your own landing page, or [override the white error page][1].

To simplify this particular situation, I updated the guide so that it uses / instead of /upload.


[1]:

[To see links please register here]

Reply

#4
Make sure that your main class is in a root package above other classes.

When you run a Spring Boot Application, (i.e. a class annotated with @SpringBootApplication), Spring will only scan the classes below your main class package.

com
+- APP
+- Application.java <--- your main class should be here, above your controller classes
|
+- model
| +- user.java
+- controller
+- UserController.java
Reply

#5
in my case it because of package position , meaning package of controller must be above main class package

if my main class package is `package co.companyname.spring.tutorial;` any controller package should `package co.companyname.spring.tutorial.WHAT_EVER_HERE;`



package co.companyname.spring.tutorial; // package for main class
@SpringBootApplication
public class FirstProjectApplication {

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


package co.companyname.spring.tutorial.controllers; // package for controllers

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

@RestController
public class HelloController {

@RequestMapping("/hello")
public String hello() {
return "Hello, world";
}}


after finish coding press boot dashboard

[![enter image description here][1]][1]


one last thing to make sure your controller is mapping or not just console you should see somehting smilliar

Mapped "{[/hello]}" onto public java.lang.String co.companyname.spring.tutorial.controllers.HelloController.hello()

happy coding


[1]:
Reply

#6
Try adding the dependency.

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
Reply

#7
All I have done to solve this kind of problem is to mention anotation **@Configuration** in MVCConfig Class.

Like this one :


package com.example;

/**
* Created by sartika.s.hasibuan on 1/10/2017.
*/
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@EnableAutoConfiguration
@Configuration
@ComponentScan
public class MvcConfig extends WebMvcConfigurerAdapter {

@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/home").setViewName("home");
registry.addViewController("/").setViewName("home");
registry.addViewController("/hello").setViewName("hello");
registry.addViewController("/login").setViewName("login");
}

}
Reply

#8
I added this dependency and it solved my problem.

<dependency>
<groupId>org.springframework.boot</groupId>

<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
Reply

#9
I had a similar mistake, I use the spring boot and velocity, my solution is to check the file application.properties, spring.velocity.toolbox-config-location found that this property is wrong
Reply

#10
You might be getting the error i.e.

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

This is because it is not scanning your Controller & Service classes which you have to specify in your main() class like this,

package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableAutoConfiguration
**@ComponentScan({"com.example.demo", "controller", "service"})**
public class SpringBootMvcExample1Application {
public static void main(String[] args) {
SpringApplication.run(SpringBootMvcExample1Application.class, args);
}
}

Note: Here, I have specified various classes like demo, controller and service to be scanned then only it will work properly.

Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

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