前言:学习的过程在于不断的总结与思考,这里记下笔者在学习过程中,所遇到的知识点,增加对框架掌握的熟悉程度。
1.环境的搭建
通过maven可以轻松搭建hibernate的环境。
1 <properties> 2 <hibernate.version>5.1.12.Final</hibernate.version> 3 <junit.version>4.12</junit.version> 4 <mysql.version>5.1.38</mysql.version> 5 <log4j.version>1.2.17</log4j.version> 6 <slf4j.version>1.7.25</slf4j.version> 7 </properties> 8 9 <dependencies> 10 <!-- hibernate依赖--> 11 <dependency> 12 <groupId>org.hibernate</groupId> 13 <artifactId>hibernate-core</artifactId> 14 <version>${hibernate.version}</version> 15 </dependency> 16 17 <!-- 数据库驱动--> 18 <dependency> 19 <groupId>mysql</groupId> 20 <artifactId>mysql-connector-java</artifactId> 21 <version>${mysql.version}</version> 22 </dependency> 23 <!-- log4j--> 24 <dependency> 25 <groupId>log4j</groupId> 26 <artifactId>log4j</artifactId> 27 <version>${log4j.version}</version> 28 </dependency> 29 <dependency> 30 <groupId>org.slf4j</groupId> 31 <artifactId>slf4j-api</artifactId> 32 <version>${slf4j.version}</version> 33 </dependency> 34 <dependency> 35 <groupId>org.slf4j</groupId> 36 <artifactId>slf4j-log4j12</artifactId> 37 <version>${slf4j.version}</version> 38 </dependency> 39 40 <!-- 测试依赖--> 41 <dependency> 42 <groupId>junit</groupId> 43 <artifactId>junit</artifactId> 44 <version>${junit.version}</version> 45 </dependency> 46 </dependencies>