I am developing a Spring app and I have divided the functions and layers into separate modules in this project.
For example:
└── xx-common
└── xx-service
└── xx-web
└── xx-app
However, there are lots of beans that I have to setup, so I have many config classes where the beans created in these classes will be used in components spreaded in the modules.
So, I have two different kinds of style to manage my config classes:
First one, all-configs in one module:
All the config classes of this project in one module, so we can see all the configs in a single package.
└── xx-common
└── xx-service
└── xx-web
└── xx-app
└── com.xxx.config
└── ServiceConfig
└── DbConfig
└── WebConfig
└── MQConfig
Or, like Harry's option, I can also put all the config classes into some module more appropriate, like xx-common
:
└── xx-common
└── com.xxx.config
└── ServiceConfig
└── DbConfig
└── WebConfig
└── MQConfig
└── xx-service
└── xx-web
└── xx-app
Second one, each module only contains configs it needs:
Each module contains its own necessary config classes.
└── xx-common
└── xx-service
└── com.xxx.config
└── ServiceConfig
└── DbConfig
└── MQConfig
└── xx-web
└── com.xxx.config
└── ServiceConfig
└── WebConfig
└── xx-app
For now I am using option one, but I am not sure which kind of structure layout would be better. Can anyone give me the pros
and cons
of each style and recommend the correct style?
SecurityConfig
takes place? and what about when one service wants to use a different database in same DB engine but in a different server/config? In the first option each module loads lots of unnecessary config to application context and could conflict.config
,repository
andutils
classes in thexx-common