Springboot統合hibernate構成
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.プロファイルアプリケーション.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
...