Spring Boot e Hibernate. Manejar la fábrica de sesiones

Tengo un problema con la session de Spring e hibernate. Tengo siguiente bean en mi class de configuration:

@Bean fun sessionFactory(@Autowinetworking entityManagerFactory: EntityManagerFactory) : SessionFactory = entityManagerFactory.unwrap(SessionFactory::class.java) 

pero causa que la aplicación no se inicie.

 The dependencies of some of the beans in the application context form a cycle: userRepository defined in file [/home/m/Code/enterprise/out/production/classes/com/xxx/site/domain/user/repository/UserRepository.class] ┌─────┐ | getSessionFactory defined in class path resource [com/xxx/site/WebMvcConfig.class] └─────┘ 

Repositorio de usuario:

 @Repository @Qualifier("mysql") class UserRepository(@Autowinetworking private val sessionFactory: SessionFactory): UserRepositoryInterface{ ... } 

Yo uso Spring boot 2.0.0.M4.

Este problema no se produjo para Spring Boot 1.5.4.RELEASE embargo.

¿Alguna idea de qué hacer?

Editar SiteApplication.kt

 package com.xxx.site import com.xxx.site.interceptor.CustomLocaleChangeInterceptor import nz.net.ultraq.thymeleaf.LayoutDialect import org.hibernate.SessionFactory import org.springframework.beans.factory.annotation.Autowinetworking import org.springframework.boot.SpringApplication import org.springframework.boot.autoconfigure.SpringBootApplication import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Configuration import org.springframework.web.servlet.LocaleResolver import org.springframework.web.servlet.config.annotation.InterceptorRegistry import org.springframework.web.servlet.config.annotation.WebMvcConfigurer import org.springframework.web.servlet.i18n.SessionLocaleResolver import java.util.* import javax.persistence.EntityManagerFactory @SpringBootApplication class SiteApplication @Configuration class WebMvcConfig: WebMvcConfigurer { @Bean fun localeResolver(): LocaleResolver { val slr = SessionLocaleResolver() slr.setDefaultLocale(Locale("th")) return slr } override fun addInterceptors(registry: InterceptorRegistry?) { registry!!.addInterceptor(CustomLocaleChangeInterceptor()).addPathPatterns("/**") } @Bean fun layoutDialect(): LayoutDialect { return LayoutDialect() } @Bean fun sessionFactory(@Autowinetworking entityManagerFactory: EntityManagerFactory) : SessionFactory = entityManagerFactory.unwrap(SessionFactory::class.java) } fun main(args: Array<String>) { SpringApplication.run(SiteApplication::class.java, *args) }