Search code examples
javaspringjakarta-eepojo

Calling Spring Based web application Classes from POJO


I have a WEB Application. I was asked to Call a Class (Service) inside the Spring application from a POJO.

The Service is not exposed either as Webservice or REST. I was just the application as a jar. I had to add this to build path and call the service.

Will it work??

Am terribly confused!


Solution

  • There's not a lot of detail in here, but I'm assuming this is a Spring application using Spring MVC, in which case yes, there's no reason why you can't call the service as a class.

    This is why you can use JUnit to test @Controller classes in Spring, it's literally just a POJO.

    Link below as an example of how to do this.

    How to unit test a Spring MVC controller using @PathVariable?