rest controller not working in spring boot

Could it be because it cant find the controller ? If yes, may you try this using @ComponentScan ? @ComponentScan tells Spring to look for other components, configurations, and services in the hello package, allowing it to find the controllers.

@SpringBootApplication
@ComponentScan(basePackageClasses = TestController.class)
@EnableConfigurationProperties({TeacherMateSettings.class})
public class JobScheduleApplication {
//Your code here
}

I finally figured it out.

I write a while loop in a method which has the @PostConstruct Annotation.It must block the spring main process, causing the rest controller not being loaded.

How foolish am I.


So basically your application main method is not able to identify the controller,service,entity etc. First please make sure you are using for their respective classes. like @Restcontroller for your controller class

@RestController
@service
@Entity
@JPARepository

Also, Make sure you are asking the spring boot application to check for these classes in the different packages

@ComponentScan({"com.funky.classes.controller","com.funky.classes.service"})
@EntityScan("com.funky.classes.model")
@EnableJpaRepositories("com.funky.classes.repository")
@SpringBootApplication()...