简体   繁体   English

JBoss的Maven + Spring架构

[英]Maven + Spring architecture for jboss

I'm creating a maven modules of spring + jersey+ mybatis application in a jboss server. 我正在jboss服务器中创建spring + jersey + mybatis应用程序的maven模块。 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*. 每个app-module *都具有app-lib的依赖关系,每个app-module *都不引用任何其他app-module *。 All the DAOs, Services etc., should be contained within itself, except the app-lib(utilities, logging etc.,). 除app-lib(实用程序,日志记录等)外,所有DAO,服务等都应包含在其内部。

Note: Jboss datasource has a jndi name app.module.ds . 注意:Jboss数据源具有jndi名称app.module.ds

-> Now the question is, what is the best way to configure the spring datasource bean for this type of application? ->现在的问题是,为这种类型的应用程序配置spring datasource bean的最佳方法是什么?

  1. Can 'datasource' bean be created per app-module*? 可以为每个应用模块创建“数据源” bean *吗?
  2. Or should I create a 'datasource' bean in the common library 'app-lib' and share it among the applications? 还是应该在公共库“ app-lib”中创建“数据源” bean并在应用程序之间共享?

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. 如果模块要一起工作并作为一个大型主应用程序混合使用,则您希望在一个地方配置事务,AOP服务,日志记录,安全性等。 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. 然后,我认为您需要将所有这些bean放在一个单独的位置,例如您的app-lib模块,或者放在一个新的模块中,以处理这类配置。 An easy to read article about cross-cutting concerns . 一篇易于理解的有关横切关注点的文章。

... ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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