Search code examples
spring-bootspring-restcontroller

Spring Boot REST Controller as External Dependency


I have a SpringBoot REST service (App 1) that exposes some end points to return some data. You can think the application as a monitoring agent.

Any other application should be able to include my SpringBoot REST service as Maven dependency.

However, when I tested this on a second application (App 2), the REST endpoints of my SpringBoot REST service (App1 included as Maven Dependency) is not getting mapped and therefore not accessible.

What is the correct way?


Solution

  • I did something like this some time ago.

    In you external dependencies you might want to remove the Spring Boot Maven plugin because you don't want executable jar.

    Then add the jar as dependency to your project and make sure you scan it.

    @ComponentScan(basePackages = {"com.your.project", "com.external.dependency"})