简体   繁体   中英

Spring + Hibernate implementation in multi-modules

My problem - for the study Spring I write a not great application composed of several modules (multimoduls).

 module1
    src
      entity
      dao
    resource
        spring-config.xml ---> This is DataSource, SessionFactory, TransactionManager
 module2
    src
      entity
      dao
    resource
        spring-config.xml ---> This is DataSource, SessionFactory, TransactionManager
 service1
     src
       service_for_module1
     resource
       spring-config.xml ---> Initialization bean Service1 (used for module1)
 service2
     src
       service_for_module2
     resource
       spring-config.xml ---> Initialization bean Service2 (used for module2)
  web
    src
      ManagerBeanForJSF
    web
      pages
      WEB-INF
        spring 
            spring-config.xml ---> Import all spring config from modules

I have exception org.hibernate.hql.internal.ast.QuerySyntaxException . When I did not have module2 - all worked successfully. Error associated with duplication of SessionFactory and TransactionManager? Can you give an example of application in Spring composed of several modules. Thanks.

我建议您使用maven项目并发布poms,以便我们可以清楚地看到项目之间的依赖关系。

As your question is a bit incomplete I can only guess you're using maven. Right? Anyway, when using Spring you should definitely, as you already wrote yourself, define the infrastructural part in one common module. Spring provides the possibility to include other context files. Even with wildcards. So you could define one singular main context file that loads those of all others in one go. The best is to have some sort of naming conventions, so that each module can easily contribute its context files.

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