第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

Configuration config = new Configuration().configure(); 一直報(bào)空指針異常

//1.創(chuàng)建一個(gè)配置對(duì)象

Configuration config = new Configuration().configure();

//2.創(chuàng)建服務(wù)注冊(cè)對(duì)象

// ServiceRegistry serviceRegistry =new?

// ServiceRegistryBuilder().applySettings(config.getProperties()).build();

StandardServiceRegistryBuilder ssrb = new?

StandardServiceRegistryBuilder().applySettings(config.getProperties());

StandardServiceRegistry ssr = ssrb.build();

//3.創(chuàng)建sessionFactory 會(huì)話工廠

SessionFactory sf = config.buildSessionFactory(ssr);

Session session =sf.getCurrentSession();

//創(chuàng)建SchemaExport 生成表結(jié)構(gòu)

SchemaExport export =new SchemaExport(config);

export.create(true, true);


<property name="connection.username">root</property>

<property name="connection.password">123456</property>

<property name="connection.driver_class">com.mysql.jdbc.Driver</property>

<property name="connection.url">jdbc:mysql://localhost:3306/test?useUnicode=true&amp;characterEncoding=UTF-8</property>

<property name="dialect">org.hibernate.dialect.MySQLDialect</property>

<property name="show_sql">true</property>


<property name="format_sql">true</property>


<property name="hbm2ddl.auto">update</property>


<property name="hibernate.current_session_context_class">thread</property>

<!--對(duì)應(yīng)的映射 -->

<mapping resource="entity/Students.hbm.xml" />

<mapping resource="entity/Users.hbm.xml" />


我實(shí)在在不到方法求問慕課的朋友們幫忙一下

正在回答

3 回答

同樣的問題,請(qǐng)問怎么解決的?


0 回復(fù) 有任何疑惑可以回復(fù)我~

我也遇到了這樣的情況,不知怎么解決

0 回復(fù) 有任何疑惑可以回復(fù)我~

//創(chuàng)建配置對(duì)象

Configuration config=new Configuration().configure(); ? /*configure()會(huì)默認(rèn)在CLASSPATH下面尋找hibernate.cfg.xml文件

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 如果沒找到,拋出異常hibernateException;

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? */

//創(chuàng)建服務(wù)注冊(cè)對(duì)象

ServiceRegistry serviceRegistry=new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();

//創(chuàng)建會(huì)話工廠對(duì)象

sessionFactory=config.buildSessionFactory(serviceRegistry);

//創(chuàng)建會(huì)話對(duì)象

session=sessionFactory.openSession();

//開啟事務(wù)

transaction=session.beginTransaction();


你改成這樣試一下

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

Configuration config = new Configuration().configure(); 一直報(bào)空指針異常

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)