There is a multi-model maven project, with dir layout as following:
xxx-parent/ common/ common-web/ member-api/ admin-api/ market-service/ ...
As you can see, there is a parent pom, and multiple sub modules, the common
or common-xxx
modules are the commons parts, which would be dependencies of other non-common modules, for code reuse.
Questions
- A. Where would you put the
model
classes, which are usually POJO, with private fields, and getter/setters.
These models might be reused by multiple non-common sub modules, (e.g bothmarket-service
andadmin-api
). - B. For some api, those model could be reused in the returned json, but only need part of the fields, would you create a separate POJO (usually I call it
entity
) for that case? And, if so, you would probably put it in the specific sub module (e.g admin-api), not the common projects, right? - C. If this is a
spring-boot
based project, and it useRedis
, and we wrote a redis util, which could be reused for most redis operations.
The problem is if we put the redis util and its maven dependencies into common, then it will connect to redis on application start automatically, but some of the sub modules don't need redis.
The solutions I am considering are:- Create a separate sub module
common-redis
for the util.
But there would be other utils too (e.gcommon-jdbc
), and there seems to be too much of common modules. - Disable sprint-boot's auto config for a specific feature (e.g redis) via
@EnableAutoConfiguration
, so that, it won't try to connect to redis on start.
- Create a separate sub module