当前位置: 代码迷 >> 综合 >> spring boot + jpa报错:No CurrentSessionContext configured
  详细解决方案

spring boot + jpa报错:No CurrentSessionContext configured

热度:14   发布时间:2023-11-24 09:07:42.0

解决办法
1.核心配置文件中要配置方言

spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect

2.之后添加

spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext

附上本人完整配置文件:

# server
server.port=8081
server.context-path=/# logs
logging.path=/var/log/demo-activiti-0108-v2-log# root level
logging.level.root=INFO# package level
logging.level.com.activiti=DEBUG# datasource
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/admineap_init
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.hibernate.ddl-auto=none# activiti default configuration
spring.activiti.check-process-definitions = falsespring.activiti.db-identity-used=false##thymeleaf
spring.thymeleaf.mode=LEGACYHTML5
spring.thymeleaf.cache=falsespring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.properties.hibernate.current_session_context_class=org.springframework.orm.hibernate5.SpringSessionContext

 

  相关解决方案