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

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

哪里錯(cuò)了???

java.lang.Error: Unresolved compilation problems:?

Cannot instantiate the type Configuration

Syntax error, insert ";" to complete BlockStatements

SerceRegistry cannot be resolved to a type

The method getproperties() is undefined for the type Configuration

Syntax error, insert ":: IdentifierOrNew" to complete ReferenceExpression

Syntax error, insert ";" to complete Statement

b cannot be resolved or is not a field

Type mismatch: cannot convert from org.hibernate.Transaction to javax.transaction.Transaction


at StudentsTest.init(StudentsTest.java:23)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)

at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)

at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)

at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)

at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)

at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)

at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)

at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)

at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)

at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)

at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)

at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)

at org.junit.runners.ParentRunner.run(ParentRunner.java:300)

at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)

at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)

at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)


正在回答

2 回答

import java.util.Date;

//import javax.transaction.Transaction;

import org.hibernate.Session;

import org.hibernate.SessionFactory;

import org.hibernate.Transaction;

import org.hibernate.cfg.Configuration;

import org.hibernate.service.ServiceRegistry;

import org.hibernate.service.ServiceRegistryBuilder;


import org.junit.After;

import org.junit.Before;

import org.junit.Test;




//測試類


public class StudentsTest {


private SessionFactory sessionFactory;

private Session session;

private Transaction transaction;

@Before

public void init(){

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

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

? //創(chuàng)建服務(wù)注冊對象

//serviceRegistry serviceRegistry =new ServiceRegistryBuilder().applySettings(config.getProperty());

//這里有錯(cuò)誤,轉(zhuǎn)換不了,用了強(qiáng)制轉(zhuǎn)換

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

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

sessionFactory =config.buildSessionFactory(serviceRegistry);

//會(huì)話對象

session = sessionFactory.openSession();

//開啟事務(wù)

? ? ? transaction = session.beginTransaction();

}

@After

public void destory(){

transaction.commit();//提交事務(wù)

session.close(); ? ? //關(guān)閉會(huì)話

sessionFactory.close();//關(guān)閉會(huì)話工廠

}

@Test

public void testSaveStudents(){

? ?//生成學(xué)生對象

Students s = new Students(1,"張三豐","男",new Date(),"武當(dāng)山");

session.save(s);//保存對象進(jìn)入數(shù)據(jù)庫

}

}


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

貼下源碼部分吧,這個(gè)分析不全

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

會(huì)笑的南瓜

b cannot be resolved or is not a field,這塊兒說 b 這個(gè)變量有問題
2017-02-28 回復(fù) 有任何疑惑可以回復(fù)我~
#2

會(huì)笑的南瓜

Type mismatch: cannot convert from org.hibernate.Transaction to javax.transaction.Transaction 是不是引用錯(cuò)了
2017-02-28 回復(fù) 有任何疑惑可以回復(fù)我~
#3

qq_孤獨(dú)的根號三_3 提問者 回復(fù) 會(huì)笑的南瓜

可是沒有用到b變量啊
2017-02-28 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

哪里錯(cuò)了???

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

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

幫助反饋 APP下載

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

公眾號

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