SpringBoot 启动的时候提示 Field *** in *** required a bean named 'entityManagerFactory' that could not be found.
错误截图
后面发现原来和入口类代码有关。
- //@SpringBootApplication(scanBasePackages = {"org.jzc.odata.cboard","org.jzc.odata.cboard.odataservice","com.sdl.odata.api.service","com.sdl.odata.api.service.ODataService"})
- @EnableAutoConfiguration(exclude = {HibernateJpaAutoConfiguration.class
- , DataSourceAutoConfiguration.class,
- DataSourceTransactionManagerAutoConfiguration.class })
- @Configuration
- @Import({
- ODataDataSourceConfiguration.class,
- ODataServiceConfiguration.class
- })
- @ComponentScan
- @RestController
- @ComponentScan(basePackages = {"org.jzc.odata.cboard","org.jzc.odata.cboard.odataservice","com.sdl.odata.api.service","com.sdl.odata.api.service.ODataService"})
- public class ServiceContainer {
其中
- @EnableAutoConfiguration(exclude = {HibernateJpaAutoConfiguration.class
- , DataSourceAutoConfiguration.class,
- DataSourceTransactionManagerAutoConfiguration.class })
这段的解释如下,
参考
https://stackoverflow.com/questions/45350546/entitymanagerfactory-not-found-in-springboot
也就是说,不去掉@EnableAutoConfiguration 和里面exclude 包含对EntityManagerFactory 的注释的话,EntityManagerFactory是不会被实例化的,这样肯定就不能发现entityManagerFactory的Bean了。
那么解决方案就是把这段注释掉,重新编译打包
- //@SpringBootApplication(scanBasePackages = {"org.jzc.odata.cboard","org.jzc.odata.cboard.odataservice","com.sdl.odata.api.service","com.sdl.odata.api.service.ODataService"})
- //@EnableAutoConfiguration(exclude = {HibernateJpaAutoConfiguration.class
- // , DataSourceAutoConfiguration.class,
- // DataSourceTransactionManagerAutoConfiguration.class })
- @Configuration
- @Import({
- ODataDataSourceConfiguration.class,
- ODataServiceConfiguration.class
- })
- @ComponentScan
- @RestController
- @ComponentScan(basePackages = {"org.jzc.odata.cboard","org.jzc.odata.cboard.odataservice","com.sdl.odata.api.service","com.sdl.odata.api.service.ODataService"})
- public class ServiceContainer {
再运行,成功了!
SpringBoot 启动的时候提示 Field *** in *** required a bean named 'entityManagerFactory' that could not be found.的更多相关文章
- springboot jpa mongodb 整合mysql Field in required a bean of type that could not be found Failed to load ApplicationContext
1.完整报错 *************************** APPLICATION FAILED TO START *************************** Descripti ...
- TClientDataSet 提交时提示 Field value Required 但是未提示具体哪个字段。
TClientDataSet 提交时提示 Field value Required 但是未提示具体哪个字段. 这个错误特别麻烦,要使用 midas 控件时,虽然很方便.但是出错了根本找不到原因,特别是 ...
- 2. springboot启动报错:Field userMapper in com.service.UserService required a bean of type 'com.dao.UserMapper' that could not be found.
报错信息: 2018-06-25 14:26:17.103 WARN 49752 --- [ restartedMain] ationConfigEmbeddedWebApplicationCon ...
- SpringBoot启动项目时提示:Error:java: 读取***.jar时出错;
场景 在IDEA中新建SpringBoot项目后,修改了默认的Maven仓库和配置文件,然后在启动项目时提示: Error:java: 读取\org\assertj\assertj-core\3.11 ...
- SpringBoot启动项目时提示:Error:(3, 32) java: 程序包org.springframework.boot不存在
场景 在IDEA中新建SpringBoot项目,后启动项目时提示: Error:(3, 32) java: 程序包org.springframework.boot不存在 实现 将pom.xml中par ...
- SpringBoot中service注入失败(A component required a bean of type 'XXService' that could not found)
先写了JUnit,发现启动不了,注释掉有问题的service也不可以.可能是因为spring开始时会加载所有service吧. 按照网友们的说法,一般需要检查: 1.入口类有没有写MapperScan ...
- A component required a bean named xxx that could not be found. Action: Consider defining
0 环境 系统:win10 1 正文 https://stackoverflow.com/questions/44474367/field-in-com-xxx-required-a-bean-of- ...
- 运行springboot项目报错:Field userMapper in XX required a bean of type 'xx' that could not be found.
运行springboot项目报错: *************************** APPLICATION FAILED TO START ************************** ...
- myeclipse2015不能启动tomcat,提示: Several ports (8005, 8080, 8009) required by Tomcat v7.0 Server at local
myeclipse2015不能启动tomcat,提示: Several ports (8005, 8080, 8009) required by Tomcat v7.0 Server at local ...
随机推荐
- 在centos6.3_64bit 上的GO语言开发环境搭建
1.下载go安装包 http://golang.org/ go1.2.linux-amd64.tar.gz 2.配置环境变量 3.编写helloworld package main import ...
- c/c++笔试面试试题
C 试题(纯属转载) 1.求下面函数的返回值(微软) int func(x) { int countx = 0; while(x) { countx ++; ...
- Git blame
一.简介 git blame可以将文件中的每一行的作者.最新的变更提交和提交时间展示出来. 二.实例 http://blog.csdn.net/hudashi/article/details/76 ...
- scrapy框架 小知识
持久化 去重规则 深度 cookie start_url 深度和优先级 下载中间件 持久化 步骤 pipeline/items a. 先写pipeline类 class XXXPipeline(obj ...
- HBase批量插入的简单代码
由于项目需要从HBase里读取数据,进行MapReduce之后输出到HDFS中. 为了测试方便,我这里写了一个批量插入HBase数据的测试代码.采用的Maven工程. 打算,今后的所有用到的小测试例子 ...
- springMVC框架集成tiles模板
将tiles模板集成到springMVC框架下,大概流程如下: 1.在配置文件中加入tiles支持 我的servlet配置文件名为spring-mvc.xml.具体配置如下: <?xml ver ...
- SpringMVC的问题No mapping found for HTTP request with URI
做了一个屏蔽进数据库的操作: Applicaition.xml配置: <?xml version="1.0" encoding="UTF-8"?> ...
- UVa 12342 Tax Calculator (水题,纳税)
今天在uva看到一个水题,分享一下. 题意:制定纳税的总额,有几个要求,如果第一个180000,不纳,下一个300000,纳10%,再一个400000,纳15%,再一个300000,纳20%,以后的纳 ...
- Cannot evaluate the property expression "$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBuildExtensionsPath32)\Microsoft.Cpp\v4.0\V140\'))" found at "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuil
Cannot evaluate the property expression "$([MSBuild]::ValueOrDefault('$(VCTargetsPath)','$(MSBu ...
- ZookeeperGettingStarted
reference url: http://zookeeper.apache.org/doc/trunk/zookeeperStarted.html#sc_FileManagement ZooKee ...