为了账号安全,请及时绑定邮箱和手机立即绑定

INFO: HHH000206: hibernate.properties not found

StudentTest.java
import java.util.Date;

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(){
  //创建配置对象
  Configuration config = new Configuration().configure();
  //创建服务注册对象
  ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();
  //创建会话工厂对象
  sessionFactory = config.buildSessionFactory(serviceRegistry);
  //会话对象
  session = sessionFactory.openSession();
  //开启事物
  transaction = session.beginTransaction();
 }
 
 @Test
 public void testSaveStudents(){
  //生成学生对象
  Student s = new Student(1,"吕不韦","男",new Date(),"秦国");
  session.save(s);
 }
 
 @After
 public void destrory(){
  //提交事物
  transaction.commit();
  //关闭会话
  session.close();
  //释放资源
  sessionFactory.close();
 }
}
hibernate.cfg.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
  "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
  "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
    <property name="connection.username">root</property>
    <property name="connection.password"></property>
    <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="connection.url">jdbc:mysql://127.0.0.1:3306/hibernate?useUnicode=true&amp;characterEncoding=UTF-8</property>
    <property name="dialect">org.hibernate.dialect.MySOLDialect</property>
    <property name="show_sql">true</property>
    <property name="format_sql">true</property>
    <property name="hbm2ddl.auto">create</property>
    <mapping resource="Student.hbm.xml" />
    </session-factory>
</hibernate-configuration>


错误信息:
十一月 08, 2016 9:25:15 上午 org.hibernate.annotations.common.Version <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.2.Final}
十一月 08, 2016 9:25:15 上午 org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.2.4.Final}
十一月 08, 2016 9:25:15 上午 org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
十一月 08, 2016 9:25:15 上午 org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
十一月 08, 2016 9:25:15 上午 org.hibernate.cfg.Configuration configure
INFO: HHH000043: Configuring from resource: /hibernate.cfg.xml
十一月 08, 2016 9:25:15 上午 org.hibernate.cfg.Configuration getConfigurationInputStream
INFO: HHH000040: Configuration resource: /hibernate.cfg.xml
十一月 08, 2016 9:25:15 上午 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
十一月 08, 2016 9:25:15 上午 org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: Student.hbm.xml
十一月 08, 2016 9:25:15 上午 org.hibernate.internal.util.xml.DTDEntityResolver resolveEntity
WARN: HHH000223: Recognized obsolete hibernate namespace http://hibernate.sourceforge.net/. Use namespace http://www.hibernate.org/dtd/ instead. Refer to Hibernate 3.6 Migration Guide!
十一月 08, 2016 9:25:15 上午 org.hibernate.cfg.Configuration doConfigure
INFO: HHH000041: Configured SessionFactory: null
十一月 08, 2016 9:25:15 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000402: Using Hibernate built-in connection pool (not for production use!)
十一月 08, 2016 9:25:15 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000115: Hibernate connection pool size: 20
十一月 08, 2016 9:25:15 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000006: Autocommit mode: false
十一月 08, 2016 9:25:15 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000401: using driver [com.mysql.jdbc.Driver] at URL [jdbc:mysql://127.0.0.1:3306/hibernate?useUnicode=true&characterEncoding=UTF-8]
十一月 08, 2016 9:25:15 上午 org.hibernate.service.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
INFO: HHH000046: Connection properties: {user=root, password=****}



正在回答

2 回答

hibernate.properties中的是否有密码

0 回复 有任何疑惑可以回复我~
#1

陷入编程无法自拔的江北 提问者

没有。已经找到答案了,cfg.xml文件里面有一个字母写错了···谢谢哈!
2016-11-08 回复 有任何疑惑可以回复我~
#2

慕九州9769075 回复 陷入编程无法自拔的江北 提问者

哪里写错了?
2016-12-14 回复 有任何疑惑可以回复我~

最后怎么解决的,分享一下啊

0 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

INFO: HHH000206: hibernate.properties not found

我要回答 关注问题
意见反馈 帮助中心 APP下载
官方微信