Spring hibernate配置中mappingLocations、mappingDirecto

來源:互聯網
上載者:User

標籤:使用   檔案   io   re   c   ar   res   app   

mappingLocations、mappingDirectoryLocations與mappingJarLocations 區別
由於spring對hibernate設定檔hibernate.cfg.xml的整合相當好,
所以,在項目中我一直使用spring的org.springframework.orm.hibernate.LocalSessionFactoryBean來取代hibernate.cfg.xml檔案的功能
LocalSessionFactoryBean有好幾個屬性用來尋找hibernate對應檔:mappingResources、mappingLocations、mappingDirectoryLocations與mappingJarLocations
他們的區別:
mappingResources:指定classpath下具體對應檔名

petclinic.hbm.xml

mappingLocations:可以指定任何檔案路徑,並且可以指定首碼:classpath、file等

/WEB-INF/petclinic.hbm.xml


classpath:/com/company/domain/petclinic.hbm.xml

也可以用萬用字元指定,????*????指定一個檔案(路徑)名,????**????指定多個檔案(路徑)名,例如:

classpath:/com/company/domain/**/maps/*.hbm.xml

上面的配置是在com/company/domain包下任何maps路徑下的hbm.xml檔案都被載入為對應檔
mappingDirectoryLocations:指定映射的檔案路徑
mappingJarLocations:指定載入的對應檔在jar檔案中

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.