spring boot - How autowire SessionFactory in Hibernate 5? -


i try autowire sessionfactory, error:

application failed start ***************************  description:  field bookrepository in com.test.app.bookservice required bean named 'entitymanagerfactory' not found. 

here autowire sessionfactory:

@service class testclass{     @autowired     lateinit var sessionfactory: sessionfactory ...... } 

this config class:

@configuration class springconfig {     @bean     fun sessionfactory(emf: entitymanagerfactory): hibernatejpasessionfactorybean {         val fact = hibernatejpasessionfactorybean()         fact.entitymanagerfactory = emf         return fact     } } 

i try way to:

@configuration class springconfig {     @bean     fun sessionfactory(): hibernatejpasessionfactorybean {         return hibernatejpasessionfactorybean()     } } 

my application.yml:

spring:     datasource:         driver-class-name: org.postgresql.driver         url: datasource_url         password: password         username: username         hikari:             maximum-pool-size: 5     jpa:         properties:             hibernate:                 jdbc:                     batch_size: 20                 current_session_context_class: org.springframework.orm.hibernate5.springsessioncontext 

hibernate version: 5.4.1

spring boot version: 2.0.0.m3


Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -