Getting “No message available” error with Spring Boot + REST application

后端 未结 10 2495
感动是毒
感动是毒 2020-12-30 02:02

I have created demo Spring Boot project and implemented Restful services as shown here

@RestController
public class GreetingsController {
    @RequestMappin         


        
10条回答
  •  被撕碎了的回忆
    2020-12-30 02:22

    You're probably missing @SpringBootApplication:

    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    
    @SpringBootApplication
    public class Application {
    
        public static void main(String[] args) throws Exception {
            SpringApplication.run(Application.class, args);
        }
    }
    

    @SpringBootApplication includes @ComponentScan which scans the package it's in and all children packages. Your controller may not be in any of them.

提交回复
热议问题