in my case it because of package position , meaning package of controller must be above main class package
if my main class package is package co.companyname.spring.tutorial;
any controller package should package co.companyname.spring.tutorial.WHAT_EVER_HERE;
package co.companyname.spring.tutorial; // package for main class
@SpringBootApplication
public class FirstProjectApplication {
public static void main(String[] args) {
SpringApplication.run(FirstProjectApplication.class, args);
}
}
package co.companyname.spring.tutorial.controllers; // package for controllers
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@RequestMapping("/hello")
public String hello() {
return "Hello, world";
}}
after finish coding press boot dashboard
one last thing to make sure your controller is mapping or not just console you should see somehting smilliar
Mapped "{[/hello]}" onto public java.lang.String co.companyname.spring.tutorial.controllers.HelloController.hello()
happy coding