6

I have a web application with different features such as map view, dashboard, report etc. But now, we are planning to split the application in different modules such as map module, dashboard module, etc. to make plug-gable as per the requirement. As all the modules will have their respective htmls, js, controllers, dao layers, how can be these divided as independent modules? Will it be a war or a jar files? Need a suggestion or example which can help me move forward.

Thanks.

GuruKulki
  • 25,776
  • 50
  • 140
  • 201

4 Answers4

3

If you have different modules, with independent features. Its possible.

I recommend you, to first, find what features are common to all web-modules, so this common-module, should be installed (as a jar for example) in the library folder of your server.

Then, all the modules could be installed in the webapps of your server (in tomcat is called as webapps).

Important:

You must be careful not to duplicate libraries in each web-module, beacause this would generate conflicts. All your common jars (libraries or your own modules should be installed in the libs folder).

If you are using maven I recommend you to have a parent maven project with all your dependencies included, and then all the modules which needs these dependencies can import it as provided.

melli-182
  • 1,216
  • 3
  • 16
  • 29
  • Thanks for your answer.. I am planning to split vertically rather than horizontally, ie, the ui, middleware and dao of each module will be in jar/war. So in that case the modules should be war files instead if jar? – GuruKulki Jul 09 '15 at 12:54
  • Hi! To answer that question I you recommend watching this link: http://stackoverflow.com/questions/5871053/java-war-vs-jar-what-is-the-difference. WAR are for web-applications commonly, so if you want to divide vertically, you should use both... – melli-182 Jul 09 '15 at 13:02
1

Microservices might be your best approach given the requirement you are sharing here. Each module i.e reporting, dashboard etc will be a separate microservice. If you use spring boot, you will end up creating multiple jar files and each jar file can be booted on the VM as a separate process and each one comes with its own container (tomcat). Makes things simple.

0

If all sub modules of your project are tightly coupled it is very difficult to split it. I suggest you to develop new different projects using reference of your old project. There is no technique to split existing project to different war files.

0

if you use Maven, you can create a parent with all common dependencies, and in its pom.xml you should define all your modules in <modules> </modules> tag. Be careful about the version of the artifacts, it should be the same version when you reference it in child pom.xml, in the parent tag.

About microservices, they are independent services and on every server is just running a single service. So, if you have multiple modules or if you more than one service on each server, it will be in conflict with MS concept.