Springboot整合Hibernate

3 篇文章 0 订阅

一、最简pom:

(springboot版本2.0.x)

1.springboot的:

spring-boot-starter

spring-boot-starter-web

spring-boot-starter-test(非必需)

2.spring data jpa的:

spring-boot-starter-jpa

3.mysql的:

mysql-connector-java

其他的话还有<parent></parent>和<plugin></plugin>

----

二、application.properties中主要配置mysql和jpa(数据源),暂时没用模板先不配springmvc,

1.mysql包括:

spring.datasource.driver-class-name=

spring.datasource.url=

spring.datasource.username=

spring.datasource.password=

2.jpa包括:

spring.jpa.database=

spring.jpa.show-sql=

spring.jpa.hibernate.ddl-auto=

spring.jpa.properties.hibernate.dialect=

----

三、dao层使用Interface XxDao extends CrudRepository,不用HibernateTemplate/sessionFactory注入

----

四、SpringBoot入口类只使用一个@SpringBootApplication注解即可,不用其他注解,但一定要放在root package下。

这点参考:https://stackoverflow.com/questions/48935864/spring-boot-scan-whole-packages-without-entityscan-enablejparepositories

关于@SpringBootApplication注解参考:https://blog.csdn.net/claram/article/details/75125749





  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值