I want to run one spring boot application, but it will listen on multiple ports.
The goal is to allow Apache to redirect multiple (sub) domains to the spring (Tomcat) boot application on different ports. Example:
example.com/** -> PORT 8080 client.example.com/** -> PORT 8090 employee.example.com/** -> PORT 8100
As far as I understand from multiple threads on SO, I'm best off running a few @SpringBootApplication annotated classes from the same main class, right? ( https://stackoverflow.com/questions/355295/... )
I still do not understand how to configure each of these applications separately.
Let's say I launched these three Applications, as shown in the related post above:
MainExampleApplication ClientExampleApplication EmployeeExampleApplication
Now, for example, I want to have separate spring Security @Configuration for each of these applications, as well as @RequestMappings , which can have the same value (for example, "/").
How do I tell the @Configuration or @Controller classes to which Application they are assigned?
Or are there properties that can be passed to applications at startup to indicate which resources are responsible for the context?
I hope I donβt go in the wrong direction. I have experience with spring MVC and have configured some fairly simplified spring applications, but not with multiple contexts. I would be very happy if someone could lead me in the right direction. Thank you in advance.
UPDATE
As mentioned in iamiddy's answer and xeon's comments, I used spring Profiles for this. I provided a SpringApplicationBuilder profile for each of the contexts of my application at startup and used @Profile("some_profile") in @Components , which should only be available for some contexts.
java spring spring-boot spring-mvc tomcat
sldk
source share