1. eureka相关异常

1.1. 异常信息

Error creating bean with name 'eurekaAutoServiceRegistration': Singleton bean creation not a

1.2. 解决

  1. 上述异常我在两处地方遇到过,一是在集成txLCN分布式服务时,用到eureka注册的时候,需要额外添加两个配置类
package com.zhiyis.framework.service.tx;

import com.codingapi.tx.netty.service.TxManagerHttpRequestService;
import com.lorne.core.framework.utils.http.HttpUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; /**
* create by lorne on 2017/11/18
*/ @Service
@Slf4j
public class TxManagerHttpRequestServiceImpl implements TxManagerHttpRequestService{ @Override
public String httpGet(String url) {
log.info("httpGet-start");
String res = HttpUtils.get(url);
log.info("httpGet-end");
return res;
} @Override
public String httpPost(String url, String params) {
log.info("httpPost-start");
String res = HttpUtils.post(url,params);
log.info("httpPost-end");
return res;
}
}
package com.zhiyis.framework.service.tx;

import com.codingapi.tx.config.service.TxManagerTxUrlService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; /**
* create by lorne on 2017/11/18
*/
@Service
@Slf4j
public class TxManagerTxUrlServiceImpl implements TxManagerTxUrlService { @Value("${tm.manager.url}")
private String url; @Override
public String getTxUrl() {
log.info("load tm.manager.url :{}", url);
return url;
}
}

否则也会报上述错误

2. 二是再junit的Test类中,用@SpringBootTest创建测试的时候,若是报上述错误,可通过在任意spring能扫到的位置添加一个类即可

package com.zhiyis.framework.lock;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.stereotype.Component; import java.util.Arrays; @Component
public class FeignBeanFactoryPostProcessor implements BeanFactoryPostProcessor { @Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
if (containsBeanDefinition(beanFactory, "feignContext", "eurekaAutoServiceRegistration")) {
BeanDefinition bd = beanFactory.getBeanDefinition("feignContext");
bd.setDependsOn("eurekaAutoServiceRegistration");
}
} private boolean containsBeanDefinition(ConfigurableListableBeanFactory beanFactory, String... beans) {
return Arrays.stream(beans).allMatch(b -> beanFactory.containsBeanDefinition(b));
}
}

参考 https://blog.csdn.net/lililuni/article/details/83105045

eureka相关异常的更多相关文章

  1. (转载)Spring的refresh()方法相关异常

    如果是经常使用Spring,特别有自己新建ApplicationContext对象的经历的人,肯定见过这么几条异常消息:1.LifecycleProcessor not initialized - c ...

  2. Eureka相关知识点

    本文讲述的是 Eureka server, 服务提供者.消费者的一些概念和配置说明. Eureka Server 服务注册中心 Eureka的高可用设计 Eureka侧重点是AP,高可用;Eureka ...

  3. JAVA Spring Cloud 注册中心 Eureka 相关配置

    转载至  https://www.cnblogs.com/fangfuhai/p/7070325.html Eureka客户端配置       1.RegistryFetchIntervalSecon ...

  4. Spring的refresh()方法相关异常

    如果是经常使用Spring,特别有自己新建ApplicationContext对象的经历的人,肯定见过这么几条异常消息:1.LifecycleProcessor not initialized - c ...

  5. SQLite相关异常

    SQLite的异常大多都和异常IO操作有关,这类异常通常在debug测试的时候难以发现通常和用户的操作有关系,根据我遇到的包括以下几种: 1.No transaction is active 这种情况 ...

  6. 【原】Maven解决jar冲突调试步骤:第三方组件引用不符合要求的javassit导致的相关异常

    [环境参数]开发框架:Spring + MyBatis + SpringMVC + KettleJDK版本:1.8.0_91javassist依赖版本:javassit-3.12.1.GA [障碍再现 ...

  7. Java基础 throws 提示调用方法时要注意处理相关异常

        JDK :OpenJDK-11      OS :CentOS 7.6.1810      IDE :Eclipse 2019‑03 typesetting :Markdown   code ...

  8. 【Nutch2.2.1基础教程之1】nutch相关异常

    1.在任务一开始运行,注入Url时即出现以下错误. InjectorJob: Injecting urlDir: urls InjectorJob: Using class org.apache.go ...

  9. windows 10下oracle相关异常及处理方法

    话说起来,不以oracle性能优化,数据库维护为主业已经有四五年了,这两年基本上以mysql为主. pl/sql登录后提示空白对话框.将ORACLE_HOME设置为oracle 11g的目录. IMP ...

随机推荐

  1. Disk

    一.简介 二.其他 1)Disk I/O

  2. touch.js 手机端的操作手势

    使用原生的touchstart总是单击.长按有冒泡冲突事件,发现百度在几年开源的touch.js库,放在现在来解决手机端的操作手势,仍然很好用.

  3. EasyPR源码剖析(6):车牌判断之LBP特征

    一.LBP特征 LBP指局部二值模式,英文全称:Local Binary Pattern,是一种用来描述图像局部特征的算子,LBP特征具有灰度不变性和旋转不变性等显著优点. 原始的LBP算子定义在像素 ...

  4. pymysql-python爬虫数据存储准备

    mongodb 和mysql 在使用哪个数据库 来存储数据上 小哥还是纠结了一下下. 很多爬虫教程都推荐mongodb 优势是速度快 因为我已经本机安装了一下 php开发环境,mysql是现成的, s ...

  5. python 解方程 和 python 距离公式实现

    解方程参考:https://zhuanlan.zhihu.com/p/24893371 缺点太慢,最后还是自己算了 距离公式参考:https://www.cnblogs.com/denny402/p/ ...

  6. 关于Https

    http://blog.csdn.net/wfdtxz/article/details/8678982 https://www.tuicool.com/articles/feYfE3I https:/ ...

  7. numpy最值

    >>> a = np.arange(9).reshape((3,3))>>> aarray([[0, 1, 2], [3, 4, 5], [6, 7, 8]])&g ...

  8. Python Day 10

    阅读目录: 函数 函数的使用 函数的分类 函数的返回值 ##函数 ##函数的定义-----what?----什么是函数: # 函数:完成 特定 功能的代码块,作为一个整体,对其进行特定的命名,该名字就 ...

  9. 第六周助教工作总结——NWNU李泓毅

    本周应批改作业23份,实际批改作业23份. 本周作业要求:https://www.cnblogs.com/nwnu-daizh/p/10569690.html 本周存在的问题: 一.github迭代过 ...

  10. HDU 6397 Character Encoding (组合数学 + 容斥)

    题意: 析:首先很容易可以看出来使用FFT是能够做的,但是时间上一定会TLE的,可以使用公式化简,最后能够化简到最简单的模式. 其实考虑使用组合数学,如果这个 xi 没有限制,那么就是求 x1 + x ...