1.could not initialize proxy - no Session
一对多,多对多关系映射中,配置的懒加载,会出现这个错误。
配置文件配置配置即可:
spring:
jpa:
open-in-view: true
properties:
hibernate:
enable_lazy_load_no_trans: true
完整配置:
server:
port: 8080
spring:
datasource:
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&useSSL=false&serverTimezone=UTC
username: root
password: root
jpa:
database: MySQL
open-in-view: true
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
show-sql: true
hibernate:
ddl-auto: update
properties:
hibernate:
enable_lazy_load_no_trans: true