0
votes

Im writing small web application using Spring Boot. Everything was working pretty fine, then I added some hibernate and Spring Security features and now my @RequestMapping doesnt work. Now i only get some logs about mapping like this:

o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]

s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public org.springframework.http.ResponseEntity> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)

s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],methods=[],params=[],headers=[],consumes=[],produces=[text/html],custom=[]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)

o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/webjars/*] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler] 2017-03-25 11:30:34.516 INFO 4644 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]

My controllers look like:

@Controller
@RequestMapping("/")
public class HomeController {

    @RequestMapping(method=RequestMethod.GET)
    public String home(Model model){
        String welcome = new String("test");
        model.addAttribute("welcome", welcome);
        return "home";
    }
}

Application.java

@Configuration      
@EnableAutoConfiguration
@EnableTransactionManagement
public class Application {

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

This is my project structure:

structure

2

2 Answers

0
votes

Problem solved. My validator class was missing @Component annotation.

0
votes

Add annotiation like below to your Application class :

// this will fix your problem (remember that by default without package declare it will look in package where Application is)
@ComponentScan("your_package_name")

// it does not require comment :)
@EnableJpaRepositories("your_package_name") 
@EntityScan("your_package_name")