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. ASP.NET Core 添加NLog日志支持(VS2015update3&VS2017)

    1.创建一个新的ASP.NET Core项目 2.添加项目依赖 NLog.Web.AspNetCore 3.在项目目录下添加nlog.config文件: <?xml version=" ...

  2. after及before伪元素及解决父元素塌陷的几种方法

    一.伪类和伪元素 CSS中伪类和伪元素有很多,也很好用!如果熟练使用的话可以解决很多问题 首先明白什么是伪类:伪类是基于当前元素的状态,而不是元素的id class等静态标志,它是动态变化的,它会在一 ...

  3. android listview里包含组件(checkbox)点击事件和Item的点击事件冲突

    在listview的item中包含有textview和checkBox.我们既想获取listitem的点击事件,又想获取listitem中textview的点击事件和listitem中checkBox ...

  4. 离线eclipse添加web工程

    下载了eclipse,先写的后台程序,后来写前台程序的时候发现没有 新建->web dynamic project,如下方式添加: 帮助->安装新软件,在work with中选择版本对应的 ...

  5. monkey测试样例

    我们通过在CMD窗口中执行: adb shell monkey {+命令参数}来进行Monkey测试了.首先,我们准备了一个有bug的项目CityWeather:通过测试这个项目(源码在附件文件夹中) ...

  6. 人力资源项目中 add_account.php

    add_account.php ( 文件浏览 ) <?phpinclude('db_con.php');   if(isset($_POST['save'])) {    $employee_i ...

  7. Vue 获取登录用户名

    本来是打算登录的时候把用户名传过去,试了几次都没成功,然后改成用cookie保存用户名,然后在读取就行了, 登录时候设置cookie setCookie(c_name,c_pwd,exdays) { ...

  8. Linux---基础命令(二)

    https://www.linuxprobe.com/chapter-02.html  (Linux就要这么学) 一.基本权限命令 权限命令:chmod - rwx rwx rwx 第一位代表的是系统 ...

  9. 复习支持向量机(SVM)没空看书时,掌握下面的知识就够了

    支持向量机(support vector machines, SVM)是一种二类分类模型.它的基本模型是定义在特征空间上的间隔最大的线性分类器:支持向量机还包括核技巧,这使它成为实质上的非线性分类器. ...

  10. 洛谷P1596 [USACO10OCT]湖计数Lake Counting

    https://www.luogu.org/problemnew/show/P1596 连通块水题... 大体思路是找到是水坑的坐标然后就开始不断递归,往八个方向搜,把连在一起的都标记一遍直到找不到为 ...