1

I wanted to create simple microservice application using 3 spring-boot applications. I have started setting the request mapping to the @RestController, but my application does not see proper mapping. I mean when I try to connect to localhost:8080/catalog/something (I have stared Tomcat Server on my own computer 8080 port, as you see), my browser sending a error, like this.

Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Tue Jun 16 13:04:34 SAMT 2020
There was an unexpected error (type=Not Found, status=404).

As I know, it means there is no mapping for this request. May be I do not know something, but I think this code should work, but not. Browser does not see the proper mapping. What is going wrong? Also I have tried set @ComponentScan annotation, but, as I have read, correct me please, there is no so need in this case. Anyway, ComponentScan annotation dose not solve my problem. Correct my if I wrong) Below I will paste the examples of my code.

This is my Controller

@RestController
@RequestMapping("/catalog")
public class MovieCatalogResource {

    @GetMapping("/{userID}")
    public List<CatalogItem> getCatalog(@PathVariable("userID") String userId) {
        return Collections.singletonList(
                new CatalogItem("", "", 10)
        );
    }
}

And this is the main (There is nothing special here, only starting the Spring-Boot application, but I guess it may be helpful for you)

@SpringBootApplication
public class MovieCatalogServiceApplication {

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

}
Bashir
  • 2,057
  • 5
  • 19
  • 44
Mikhail
  • 195
  • 2
  • 12

0 Answers0