Spring Boot Controller not mapping

前端 未结 9 1478
慢半拍i
慢半拍i 2021-02-05 02:55

I have used STS and now I am using IntelliJ Ultimate Edition but I am still getting the same output. My controller is not getting mapped thus showing 404 error. I am completely

9条回答
  •  囚心锁ツ
    2021-02-05 03:04

    Adding @ComponentScan(com.webservice) in main class above @SpringBootApplication will resolve your problem. Refer below code

    package com.webservice.demo;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.context.annotation.ComponentScan;
    
    @ComponentScan(com.webservice)
    @SpringBootApplication
    public class DemoApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(DemoApplication.class, args);
        }
    }
    

提交回复
热议问题