I would like to be able to have multiple web apps sharing a domain project and running under different contextPaths.
By setting server.contextPath=/webshop in a spring boot app I dont need to prefix all the RequestMappings.
I would like the webshop, admin, and main page to share a common domain project which contains all the entities and common services.
Maybe with something like?
public static void main(String[] args) {
new SpringApplicationBuilder(Domain.class)
.showBanner(false)
.child(Admin.class, Webshop.class)
.run(args);
}
My problem is how do I start a spring boot app with a common domain model, and then a couple of stand alone web apps with unique contextPaths?
So yes, this is expected behavior given your project setup. Put each @SpringBootApplication class in a separate subpackage if you don't want this to happen for local testing.
Like this for example:
public static void main(String[] args) {
start(Admin.class, Webshop.class).run(args);
start(Another.class).properties("server.port=${other.port:9000}").run(args);
}
private static SpringApplicationBuilder start(Class<?>... sources) {
return new SpringApplicationBuilder(Domain.class)
.showBanner(false)
.child(sources);
}
It would start two apps on different ports.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With