Reputation: 87
I have a Spring Boot RESTful microservice that a customer would like to nest inside their Spring Boot application.
Could someone tell me whether this is possible?
I was hoping this would be as simple as adding a dependency on my application in the customers maven pom file and then excluding the tomcat dependency since the customer already uses the embedded tomcat.
Thanks,
Ben
Upvotes: 4
Views: 2453
Reputation: 2371
Since they already use Spring Boot to start their app, you can simply mark all Spring Boot dependencies as provided
in your Maven POM, this would exclude it from the JAR as well as embedded Tomcat and all related dependencies. Also make sure you don't build your JAR as a Spring Boot executable (should be the default if you're not using the spring-boot-maven-plugin
).
On the customer side, they would need to include your JAR as a dependency, and possibly add a scanBasePackages
property to their @SpringBootApplication
, to auto-discover your application classes, if they don't reside in a package under the one that @springBootApplication
is on. Also, they'll need to be mindful of any URI collisions between your app and theirs, as the two will be sharing the same environment.
Upvotes: 7