I have Spring MVC project to develop sample REST api. It was running when I deploy app in tomcat. Now, I wanted to update the project with Spring boot. I have created the main spring boot application class which is as below at package: com.abc.demo.config
@EnableAutoConfiguration // Sprint Boot Auto Configuration
@ComponentScan(basePackages = "com.abc.demo")
@EnableWebMvc
public class Application extends SpringBootServletInitializer {
private static final Class<Application> applicationClass = Application.class;
private static final Logger log = LoggerFactory.getLogger(applicationClass);
public static void main(String[] args) {
SpringApplication.run(applicationClass, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(applicationClass);
}
@Bean
public DispatcherServlet dispatcherServlet() {
return new DispatcherServlet();
}
}
My controller is at com.abc.demo.Controller which is like below:
@RestController
public class MyController {
static final Logger logger = Logger.getLogger(MyController.class);
@Inject
private MyService myService;
@RequestMapping(value = "/mytask/{task}", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public int myTask(@PathVariable String task) {
return myService.service(task);
}
}
When I deploy the application in local tomcat without adding spring boot, it was deploying and I am able to see the response from the service. (I had web.xml and dispatcher servlet as well while app was running). But, when I added spring boot and run the app from command line, app is running (I have run some threads when app starts, when I can see running). But when I do curl, request is not coming to controller at all and seeing the URI not found log in console as :No mapping found for HTTP request with URI as [/[myservice-name]/myTask Did I miss something here? Appreciate if someone points out the things I missed.