使用SpringData-JPA踩的一些坑

Springcloud使用SpringData的时候踩的一些坑

最近学习springcloud的时候由于没有使用mybatis而是使用了SpringData报了一系列的错

错误1:

Caused by: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)

出现此错误只需要在数据库的连接信息加useSSL=false

在这里插入图片描述

原因是MySQL在高版本需要指明是否进行SSL连接。 

错误2:

Caused by: org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set at org.hibernate.engine.jdbc.dialect.internal.DialectFactoryImpl.determineDialect(DialectFactoryImpl.java:100) ~[hibernate-core-5.4.9.Final.jar:5.4.9.Final] 

出现此错误只需要在yml配置文件加入

spring:
   jpa:
    show-sql: true
    hibernate:
      ddl-auto: create
    database-platform: org.hibernate.dialect.PostgreSQLDialect

在这里插入图片描述

如果添加了方言还报这个错,就看下数据的连接信息有没设置时区,添加serverTimezone=UTC

jdbc:mysql://localhost:3306/test?serverTimezone=UTC

错误3:

Unknown table ‘system_sequences’ in information_schema 错误

解决方法:

字面意思应该是hibernate不知道的schema里system_sequences表,于是检查hibernate配置文hibernate.cfg.xml

发现dialect方言用错了,忘记改过来 org.hibernate.dialect.PostgreSQLDialect

我用的是mysql5.6,应该用这个 org.hibernate.dialect.MySQL5Dialect

修改后不再报Unknown table ‘system_sequences’ in information_schema错误了。
hibernate所有的方言类都放在org.hibernate.dialect包中,从hibernate3.jar中可以找到这些类。
他们均是 org.hibernate.dialect.Dialect 的子类

错误4:

'parent.relativePath' of POM com.atguigu:springcloud-parent:1.0-SNAPSHOT (D:\Java_Project\*****\******\pom.xml) points at com.***.maven:zzn-maven instead of org.springframework.boot:spring-boot-starter-parent, please verify your project structure

解决方法

在父工程加入

在这里插入图片描述

就不会提示错误

猜你喜欢

转载自blog.csdn.net/weixin_44199207/article/details/121775724