1. 添加sprngboot依赖

4.0.0
cn.tongdun.gwl
SpringBootTest
1.0-SNAPSHOT
org.springframework.boot
spring-boot-starter-parent
1.5.1.RELEASE
junit
junit
3.8.1
test
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-devtools
true
org.springframework.boot
spring-boot-starter-thymeleaf
hibernateSpringDemo
org.springframework.boot
spring-boot-maven-plugin
true
```

2.添加jpa依赖

            
org.springframework.boot
                
spring-boot-starter-data-jpa     
              
                    
                    
mysql
          
mysql-connector-java     
  

3.添加配置文件application.properties

     spring.datasource.url = jdbc:mysql://localhost:3306/test     spring.datasource.username = root     spring.datasource.password = root     spring.datasource.driverClassName = com.mysql.jdbc.Driver# Specify the DBMS

     spring.jpa.database = MYSQL

     # Show or not log for each sql queryspring.jpa.show-sql = true

     # Hibernate ddl auto (create, create-drop, update)spring.jpa.hibernate.ddl-auto = update

     # Naming strategyspring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy

     # stripped before adding them to the entity manager)spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect

 4.在main方法添加注解

    @EnableTransactionManagement // 启注解事务管理   

 @SpringBootApplication

。。。