springboot之hibernate之helloworld
springboot引入hibernate是通過spring-boot-starter-data-jpa,并沒有一個spring-boot-starter-hibernate。
然后再引入mysql的connector就可以了。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
數(shù)據(jù)庫的登錄信息配置在src/resources/application.properties里:
spring.application.name=test-hibernate
spring.datasource.url=jdbc:mysql://localhost:3306/test
spring.datasource.username=root
spring.datasource.password=1234
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
語法簡單但是奇奇怪怪。
要先在數(shù)據(jù)庫創(chuàng)建一個叫test的database,這樣就能運行了。
最后配置: win10 mysql8.4 spring-build-tool4.28

浙公網安備 33010602011771號