首页 新闻 会员 周边

hibernate!

0
悬赏园豆:15 [待解决问题]
package com.gyb.text;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.junit.Test;

import com.gyb.*;

public class test {
    @Test
    public void add(){
        
        
        Configuration cf=new Configuration().configure();
        SessionFactory factory=cf.buildSessionFactory();
        Session session=factory.openSession();
        try{
            session.beginTransaction();
            Customer customer=new Customer();
            customer.setName("zs");
            customer.setEmail("610382820@qq.com");
            customer.setPassword("root");
            customer.setPhone(1234567);
            customer.setMarried(true);
            customer.setAdress("qingdao");
            session.save(customer);
            session.getTransaction().commit();
            
        }catch(Exception e){
            
            e.printStackTrace();
            
        }finally{
            session.close();
            
            
        }
        
    }

}


错误:

java.lang.ExceptionInInitializerError  at com.gyb.text.test.add(test.java:15)  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.internal.runners.TestMethodRunner.executeMethodBody(TestMethodRunner.java:99)  at org.junit.internal.runners.TestMethodRunner.runUnprotected(TestMethodRunner.java:81)  at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)  at org.junit.internal.runners.TestMethodRunner.runMethod(TestMethodRunner.java:75)  at org.junit.internal.runners.TestMethodRunner.run(TestMethodRunner.java:45)  at org.junit.internal.runners.TestClassMethodsRunner.invokeTestMethod(TestClassMethodsRunner.java:66)  at org.junit.internal.runners.TestClassMethodsRunner.run(TestClassMethodsRunner.java:35)  at org.junit.internal.runners.TestClassRunner$1.runUnprotected(TestClassRunner.java:42)  at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:34)  at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)  at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)  at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)  at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196) Caused by: java.lang.NullPointerException  at org.slf4j.LoggerFactory.singleImplementationSanityCheck(LoggerFactory.java:192)  at org.slf4j.LoggerFactory.performInitialization(LoggerFactory.java:113)  at org.slf4j.LoggerFactory.getILoggerFactory(LoggerFactory.java:269)  at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242)  at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:255)  at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:165)  ... 21 more

你猜我是谁109的主页 你猜我是谁109 | 初学一级 | 园豆:187
提问于:2014-12-08 20:38
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册