完成5-2课程后项目无法启动

来源:5-2 后台登录功能实现

qq_拉格朗_1

2018-03-27

照着老师的代码敲完后,启动项目出现如下报错

2018-03-27 19:19:59.599  WARN 15248 --- [  restartedMain] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webSecurityConfig' defined in file [D:\Study\zufang-project\target\classes\com\jlc\config\WebSecurityConfig.class]: Initialization of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'authProvider': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'userRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userRepository': Cannot create inner bean '(inner bean)#510a2804' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#510a2804': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available

2018-03-27 19:19:59.599  INFO 15248 --- [  restartedMain] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'

2018-03-27 19:19:59.606  INFO 15248 --- [  restartedMain] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]

2018-03-27 19:19:59.623  INFO 15248 --- [  restartedMain] utoConfigurationReportLoggingInitializer : 


Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.

2018-03-27 19:19:59.745 ERROR 15248 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 


***************************

APPLICATION FAILED TO START

***************************


Description:


Field userRepository in com.jlc.service.user.UserServiceImpl required a bean named 'entityManagerFactory' that could not be found.



Action:


Consider defining a bean named 'entityManagerFactory' in your configuration.


写回答

1回答

瓦力老师

2018-03-28

亲,注意要把JPAConfig中的Bean的名字命名正确哈,你可以参考已答复该类型问题这个链接来看如何更改自己的bean的名字,祝亲学习愉快哈~

0
1
qq_拉格朗_1
非常感谢!
2018-03-31
共1条回复

BAT大牛亲授 基于ElasticSearch的搜房网实战

ES+MySQL+Kafka,打造强力站内搜索

898 学习 · 285 问题

查看课程