Embed hibernate hbm.xml mappings in jar

前端 未结 5 1075
耶瑟儿~
耶瑟儿~ 2020-12-20 00:06

Is it possible to embed the hibernate mapping hbm.xml’s to the jar and avoid manual reference in applicationContext.xml like

  

        
5条回答
  •  情书的邮戳
    2020-12-20 00:40

    Just to clarify, as well: you're specifically talking about Spring and Hibernate together, since the configuration you're showing is Spring's configuration of Hibernate. Spring's LocalSessionFactoryBean accepts a multitude of different ways to set the location of your Hibernate mapping files; you only show using the mappingResources parameter, but there's also mappingLocations, mappingJarLocations, and mappingDirectoryLocations.

    I'd think that for your example, you might want to use mappingDirectoryLocations and just point it to a specific directory within your JAR, such as:

    
          
            
              com/…/domain/
            
          
    
    

提交回复
热议问题