Kedare
Kedare

Reputation: 1277

Spring Boot MVC : URL not published but shown in the boot logs

I'm just starting a very simple Spring MVC with Spring Boot (and Groovy), and I can't get my controller to be routed correctly, for example :

package net.kedare

import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.stereotype.Controller
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RequestMethod

@SpringBootApplication
class SpringLedControllerApplication {

    static void main(String[] args) {
        SpringApplication.run SpringLedControllerApplication, args
    }
}

@Controller
@RequestMapping("/")
class SpringLedController {

    @RequestMapping(method=RequestMethod.GET)
    public String index() {
        return "Hello"
    }

}

It appears in the boot logs : 2016-01-23 14:09:28.588 INFO 57995 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/],methods=[GET]}" onto public java.lang.String net.kedare.SpringLedController.index()

But when I go to the URL : "http://localhost:8080/", I get this :

Whitelabel Error Page

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

Sat Jan 23 14:09:58 CET 2016
There was an unexpected error (type=Not Found, status=404).
No message available

Looks like it redirects to /error, but I don't know why..

Upvotes: 0

Views: 665

Answers (1)

Abdelhak
Abdelhak

Reputation: 8387

Add this dependency in your pom.xml:

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

Upvotes: 2

Related Questions