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(){
??//創(chuàng)建配置對(duì)象
??Configuration config = new Configuration().configure();
??//創(chuàng)建服務(wù)注冊(cè)對(duì)象
??ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();
??//創(chuàng)建會(huì)話工廠對(duì)象
??sessionFactory = config.buildSessionFactory(serviceRegistry);
??//會(huì)話對(duì)象
??session = sessionFactory.openSession();
??//開啟事物
??transaction = session.beginTransaction();
?}
?
?@Test
?public void testSaveStudents(){
??//生成學(xué)生對(duì)象
??Student s = new Student(1,"呂不韋","男",new Date(),"秦國(guó)");
??session.save(s);
?}
?
?@After
?public void destrory(){
??//提交事物
??transaction.commit();
??//關(guān)閉會(huì)話
??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&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>
錯(cuò)誤信息:
十一月 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=****}
2016-11-08
hibernate.properties中的是否有密碼
2017-12-31
最后怎么解決的,分享一下啊