简体   繁体   中英

Maven + Spring architecture for jboss

I'm creating a maven modules of spring + jersey+ mybatis application in a jboss server. Currently i have the following structure

app-parent
  | \   
  |  \_ app-module1
  |____ app-module2
  |____ app-module3
  |____ app-lib

Each of the app-module* has the dependency of app-lib, and each of the app-module* does not refer to any other app-module*. All the DAOs, Services etc., should be contained within itself, except the app-lib(utilities, logging etc.,).

Note: Jboss datasource has a jndi name app.module.ds .

-> Now the question is, what is the best way to configure the spring datasource bean for this type of application?

  1. Can 'datasource' bean be created per app-module*?
  2. Or should I create a 'datasource' bean in the common library 'app-lib' and share it among the applications?

Which one is better? and why?

As always, it depends on your needs.

  1. Micro-services way

If each component is a separated application and although are going to work together but not mixed, like in a micro-services fashion, then is better to have separated datasource configurations.

  1. Taking care of the transactions and other cross-cutting concerns

If the modules are going to work together and mixed as one big main application, then you want to configure the transactions, AOP service, logging, security, etc. in one single place. Then I think you need to put all of these beans in a single place like your app-lib module, or better, in a new module to handle these kind of configurations. An easy to read article about cross-cutting concerns .

...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM