I'm trying to implement a REST endpoint between two non-web applications with all configuration in XML files.
I've created a simple controller with a method that only returns "OK"
, so I can run some tests using Postman.
Unfortunately, the endpoint is not being created.
I did some research and I found out that I need to add the "context" tag with the component-scan pointing to the controller package for it to work.
But my current implementation is not enough for it to work:
<context:component-scan base-package="com.app.REST"/>
My controller class is:
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class TestController {
@RequestMapping("/test")
@ResponseBody
public String test(){
return "OK";
}
}
My question is: is there any way to create a REST endpoint without annotating the main class with @SpringBootApplication
? If yes, what am I missing? Is it something in my XML file or somewhere else?