Kadri Moujib
Kadri Moujib

Reputation: 45

Multiple Spring-Boot (Web) projects

I want to divide my project to components; each component would have its own Data, Core, Web exp >

Can I apply this architecture and run the whole project on the embedded Tomcat server on one single PORT ? Or do I have to work with microservices and run each component on its PORT ( I want to avoid this solution) ?

You can propose a similar architecture if you wish.

Thank You.

Upvotes: 1

Views: 917

Answers (2)

slim
slim

Reputation: 41223

Spring Boot gives you lots of choices - what works for you depends on your needs and preferences.

The most typical choice is to build a "fat jar" containing an embedded web server which you run with java -jar myservice.jar. If you do this, every service you deploy will need its own address/port combination.

You can run directly on a host, or use Docker, full VMs: whatever works for you.

You can of course expose them to consumers as a consolidated service using a proxy like HaProxy or Nginx.

But you can also build a WAR, to be deployed on a servlet container of your choice. See: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-traditional-deployment.html

Some containers make life a little bit difficult with their heavy-handed management of the classpath (I've struggled, but eventually succeeded, on older versions of WebLogic). But it's certainly possible to deploy three Spring Boot WARs to the same J2EE container, and of course if you do that they'll share a server socket and have a root path controlled by the container.

Upvotes: 1

Luke Bajada
Luke Bajada

Reputation: 1842

As the name implies, an embedded tomcat means that each component will have its own tomcat and thus will need its own port.

In your case though, I would have the web part which would be deployable (with embedded tomcat) and treat the data and core part as libraries to be imported by the web part (or as required).

Upvotes: 4

Related Questions