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 ...
随机推荐
- StringUtils详解
public static void StringUtil(){ //null 和 ""操作~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //判断是否 ...
- IntelliJ IDEA 注册码及相关资源
原文地址 http://idea.lanyus.com/ *.lanyus.com下的全部授权服务器已遭JetBrains封杀,请使用http://idea.qinxi1992.cn 或者搭建自己的I ...
- 03 Complementing a Strand of DNA
Problem In DNA strings, symbols 'A' and 'T' are complements of each other, as are 'C' and 'G'. The r ...
- 3.3.6-1 ArrayBlockingQueue简单分析
构造方法:public ArrayBlockingQueue(int capacity) { this(capacity, false); } public ArrayBlockingQueue(in ...
- Lucene.Net(转)
出处:http://www.cnblogs.com/piziyimao/archive/2013/01/31/2887072.html 做过站内搜索的朋友应该对Lucene.Net不陌生,没做过的也许 ...
- javascript总结47: JS动画原理&jQuery 效果- 各种动画
1 动画的原理就是: 盒子本身的位置+步长 2 什么是步长? var box=document.getElementById('box'); btn.onclick = function() { // ...
- Params应用
有时候我们要想传递可变数量的参数改怎么办??Params给我们提供了一个很好的方法 Parmas: 1.只运用方法的最后一位参数 2.这个参数只能标志任意类型的一位数组 3.添加了params这个参数 ...
- WSAStartup函数
函数WSAStartup 一.WSAStartup函数 int WSAStartup ( ...
- kafka学习默认端口号9092
一 Kafka 概述1.1 Kafka 是什么在流式计算中,Kafka 一般用来缓存数据,Storm 通过消费 Kafka 的数据进行计算.1)Apache Kafka 是一个开源消息系统(微信公众号 ...
- Apache网站服务
Apache 下载地址: http://mirror.bit.edu.cn/apache/httpd/相关软件下载地址:http://mirror.bjtu.edu.cn/apache/apr/apr ...