码迷,mamicode.com
首页 > 其他好文 > 详细

hibrenate配置

时间:2016-02-03 18:14:05      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:

配置文件配置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&amp;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>
View Code

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>
View Code

 

hibrenate配置

标签:

原文地址:http://www.cnblogs.com/fshimao/p/5180199.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!