Configuration 配置物件

2021-10-04 22:03:33 字數 1052 閱讀 2163

hibernate.cfg.xml通常使用xml配置檔案,可以配置內容更豐富。

hibernate.properties用於配置key/value 形式的內容,key不能重複的。配置有很多的侷限性。一般不用。【可以進入hibernate-distribution-3.6.10.final\project\etc目錄看內容】

這個方法可以指定配置檔案路徑

一種是在hibernate.cfg.xml配置,另一種是**設定

重複了對映檔案

注意:平時開發中:將

hbm.xml對映配置

hibernate.cfg.xml

載入對映檔案三種方法

1、常用

configuration.addclass(user.class);
另外:

需要獲取當前的session對話   

sessionfactory.getcurrentsession()需要在hibernate.cfg.xml中加入
thread
且用get獲取的session不需要關閉,提交事務會自動關閉

Configuration配置檔案的註解

配置類的註解。在meta inf spring.factories中宣告是配置類 檔案內容如下 org.springframework.boot.autoconfigure.enableautoconfiguration com.unit.db.starter.datasourceautoconfi...

Configuration註解 Bean註解

package com.test.spring.support.configuration configuration public class testconfiguration xmlns xmlns xsi xmlns context xmlns jdbc xmlns jee xmlns tx...

Sping中的 Configuration註解

使用要求 configuration不可以是final型別。configuration不可以是匿名類。巢狀的configuration必須是靜態類。bean類 public class testbean public string tostring public void start public ...