Project with one module and several maven modules

I am creating a new java web project. This web application will have many modules, such as core / commons, business service, repository, security, integration, ldap, user management ... I wonder if I should separate each module into each maven project (jar file) or create a project that include all Java packages of all modules in one maven project.

Structure of Multi modules maven project mycompany-core mycompany-repository mycompany-api mycompany-usermanagement mycompany-business mycompany-web Structure of Single module project: mycompany-web |___ src |____ main |____ java |____ com.mycompany.core |____ com.mycompany.repository |____ com.mycompany.business |____ com.mycompany.controller 

When should we use multi-module modules or projects with one module> Please give me some tips.

+6
source share
2 answers

All the products I worked on at Maven were multi-module. This is because they are usually large. However, when I create my own pet projects, they are usually single-module.

As a rule, as products grow, they should be organized into several modules. Some projects start as a single module and break down as they grow. Others, created by developers with wide experience, are already divided, because developers already know how the code will develop and how it needs to be organized.

In particular, from your list of "core / commons, business service, repository, security, integration, ldap, user management" I would separate "commons" in my own module, because it smells that it can be reused on other projects. The rest of the parts could fit into one module, but I would need to better understand the project.

+5
source

It depends on your requirement. If you want to run this using .sh or .bat , you should have one target (single jar with other libraries).

If your project is built as an API , it is better to have your own assembly in the form of several modules.

+1
source

Source: https://habr.com/ru/post/972681/


All Articles