标签:
配置文件配置MYSQL
1 <?xml version="1.0" encoding="UTF-8"?> 2 <!DOCTYPE hibernate-configuration PUBLIC 3 "-//Hibernate/Hibernate Configuration DTD 3.0//EN" 4 "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> 5 <hibernate-configuration> 6 <session-factory> 7 <!-- Database connection settings --> 8 <property name="connection.driver_class">org.gjt.mm.mysql.Driver</property> 9 <property name="connection.url">jdbc:mysql://127.0.0.1:3308/mytest?useUnicode=true&characterEncoding=UTF-8</property> 10 <property name="connection.username">root</property> 11 <!-- <property name="connection.password"></property> --> 12 13 <!-- JDBC connection pool (use the built-in) --> 14 <property name="connection.pool_size">10</property> 15 <property name="connection.autocommit">true</property><!-- 自动提交事物需要用到这个 --> 16 17 <!-- SQL dialect --> 18 <property name="dialect">org.hibernate.dialect.MySQL5Dialect</property> 19 20 <!-- Enable Hibernate‘s automatic session context management --> 21 <property name="current_session_context_class">thread</property> 22 23 <!-- Disable the second-level cache --> 24 <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property> 25 26 <!-- Echo all executed SQL to stdout --> 27 <property name="show_sql">true</property> 28 29 <!-- Drop and re-create the database schema on startup --> 30 <property name="hbm2ddl.auto">update</property> 31 32 <mapping resource="com/sf/sftech/postest/entity/maping/Student.hbm.xml"/> 33 </session-factory> 34 </hibernate-configuration>
Maven依赖配置
1 <dependency> 2 <groupId>org.hibernate</groupId> 3 <artifactId>hibernate-core</artifactId> 4 <version>3.6.10.Final</version> 5 </dependency> 6 <dependency> 7 <groupId>mysql</groupId> 8 <artifactId>mysql-connector-java</artifactId> 9 <version>5.1.18</version> 10 </dependency> 11 <dependency> 12 <groupId>org.javassist</groupId> 13 <artifactId>javassist</artifactId> 14 <version>3.18.1-GA</version> 15 </dependency> 16 <dependency> 17 <groupId>org.slf4j</groupId> 18 <artifactId>slf4j-nop</artifactId> 19 <version>1.7.7</version> 20 </dependency>
标签:
原文地址:http://www.cnblogs.com/fshimao/p/5180199.html