Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument
spring 5.+jpa 配置类出错:
十二月 20, 2018 5:53:01 下午 org.springframework.web.servlet.DispatcherServlet initServletBean
严重: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'studentRepository': Cannot create inner bean '(inner bean)#69ecc373' 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)#69ecc373': Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'entityManagerFactory' available
原因之一是配置类中方法名不对:
@Bean
public LocalContainerEntityManagerFactoryBean localContainerEntityManagerFactoryBean()
{
//EntityManagerFactory
LocalContainerEntityManagerFactoryBean bean=new LocalContainerEntityManagerFactoryBean();
bean.setDataSource(dataSource());
bean.setPackagesToScan(new String[] {"com.jpa.demo"});
bean.setJpaVendorAdapter(jpaVendorAdapter());
return bean;
}
必须是:entityManagerFactory:
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory()
{
//EntityManagerFactory
LocalContainerEntityManagerFactoryBean bean=new LocalContainerEntityManagerFactoryBean();
bean.setDataSource(dataSource());
bean.setPackagesToScan(new String[] {"com.jpa.demo"});
bean.setJpaVendorAdapter(jpaVendorAdapter());
return bean;
}
Cannot resolve reference to bean 'entityManagerFactory' while setting constructor argument的更多相关文章
- Cannot resolve reference to bean 'sqlSessionFactory' while setting bean
今天下载公司以前的一个项目,要和现在的项目进行整合,下载一切顺利,但在开发机器上一跑,憋了. 有两种日志,两种报错:一个是cannot resolve reference to bean 'sqlSe ...
- Error creating bean with name 'us' defined in class path resource [com/liuyang/test/DI/beans2.xml]: Cannot resolve reference to bean 'daoa' while setting bean property 'daoa'; nested exception is org.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'us' defined ...
- Error creating bean with name 'mapper' defined in class path resource [applicationcontext.xml]: Cannot resolve reference to bean 'factory' while setting bean property 'sqlSessionFactory'; nested excep
Error creating bean with name 'mapper' defined in class path resource [applicationcontext.xml]: Cann ...
- Cannot resolve reference to bean 'sessionFactory' while setting bean property 'sessionFactory'; 没有sessionFactory
maven子项目spring配置文件创建bean 没有找到另一个子项目中的bean. 需要引入另一个子项目的配置文件,仅提供测试用 如下: <!-- 仅供测试用 --> <impor ...
- Cannot resolve reference to bean 'mongoTemplate' while setting bean property 'mongoOperations'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with na
问题: Springboot 启动时出错,报没法创建bean的错误,看到nested最后是关于mongoTemplate的错误. 过程: 看网上大多说的是修改mongoTemplate的配置,但是sp ...
- 解决Cannot resolve reference to bean 'txPointcut' while setting bean property 'pointcut'
忘记导入了 这三个jar包...
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'deptDao_a' defined in class path resource [beansAndHibernate.xml]: Cannot resolve reference to bean 'sessionFact
Error creating bean with name 'deptDao_a' defined in class path 因为更改了类的名字,所以其setter方法没有更改,需要 private ...
- error: cannot lock ref 'refs/remotes/origin/master': unable to resolve reference 'refs/remotes/origin/master': reference broken...
之前在自己的项目中添加了一个分支,然后做了一些操作,比如同步本地的分支情况到远程仓库中,然后在远程仓库中完成分支合并,以及 Pull request 等等操作,后来,在本地仓库中进行 git fetc ...
- swagger list Could not resolve reference because of: Could not resolve point
swagger list Could not resolve reference because of: Could not resolve point controller的参数要加 @Requ ...
随机推荐
- 第8章7节《MonkeyRunner源代码剖析》MonkeyRunner启动执行过程-小结
最后我们对MonkeyRunner启动的过程做一个总结,当然,当中也包括启动Monkey,尽管它不属于启动过程的一部分: monkeyrunner这个shell脚本会先设置一些执行环境的系统属性保存到 ...
- 酉矩阵(unitary matrix)
复方阵 U 称为酉矩阵,如果满足: U∗U=UU∗=I 换句话说,矩阵 U 的共轭转置 U∗ 就是 U 的逆矩阵. U∗=U−1 1. unitary matrix 保持内积不变 ⟨Ux,Uy⟩=⟨x ...
- 120.VS调试技巧
设置断点调试 在一行代码的左侧点击即可设置断点,按F5(调试->开始调试)即可运行到第一个端点处暂停 逐语句调试 按F11(调试->逐语句)即可开始一步一步执行 逐过程调试 按F10(调试 ...
- janos.io
http://janos.io/ https://developer.mozilla.org/en-US/Firefox_OS/Developing_Firefox_OS/Porting
- Exercise : Self-Taught Learning
First, you will train your sparse autoencoder on an "unlabeled" training dataset of handwr ...
- 今日SGU 5.3
SGU 107 题意:输入一个N,表示N位数字里面有多少个的平方数的结尾9位是987654321 收获:打表,你发现相同位数的数相乘结果的最后几位,就和那两个相乘的数最后几位相乘一样,比如3416*8 ...
- JNDI学习总结(3)——Tomcat下使用C3P0配置JNDI数据源
一.C3P0下载 C3P0下载地址:http://sourceforge.net/projects/c3p0/files/?source=navbar 下载完成之后得到一个压缩包. 二.使用C3P0配 ...
- 【吴节操点评】中国企业SaaS应用深谙未来者寥寥数几 两极分化将加剧
数年前,在国外企业级应用如火如荼的时候.国内却是一片空白.而现在企业SaaS应用市场,包含用友.金蝶.东软在内的三巨头.已经有数十家之多.相比美国3000亿美元的企业应用三巨头来说,中国企业应用前三甲 ...
- 微软自拍应用iOS版公布
微软自拍(Microsoft Selfie)主要是支持自拍后还能加强自拍效果的功能. 只是和其它自拍应用不同的是.Microsoft Selfie 利用了机器学习来增强照片,应用会"考虑年龄 ...
- Cannot use isset() on the result of an expression (you can use "null !== expression" instead)
if (isset($array[2])){ 抛出错误 Cannot use isset() on the result of an expression (you can use "nu ...