EurekaClient项目启动报错Invocation of destroy method failed on bean with name 'scopedTarget.eurekaClient': org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'e
Disconnected from the target VM, address: '127.0.0.1:51233', transport: 'socket'
Eureka Client的使用
使用IDEA创建一个Spring Initializr项目,在勾选模块的时候需要选择Eureka Discovery,如下:
项目生成的pom.xml文件内容如下:
- <?xml version="1.0" encoding="UTF-8"?>
- <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.zero.eureka</groupId>
- <artifactId>client</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <packaging>jar</packaging>
- <name>client</name>
- <description>Demo project for Spring Boot</description>
- <parent>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-parent</artifactId>
- <version>2.0.4.RELEASE</version>
- <relativePath/> <!-- lookup parent from repository -->
- </parent>
- <properties>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
- <java.version>1.8</java.version>
- <spring-cloud.version>Finchley.SR1</spring-cloud.version>
- </properties>
- <dependencies>
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
- </dependency>
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-test</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.springframework.cloud</groupId>
- <artifactId>spring-cloud-dependencies</artifactId>
- <version>${spring-cloud.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
- <build>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- </plugin>
- </plugins>
- </build>
- </project>
项目的依赖都加载完成后,在启动类中加上@EnableDiscoveryClient,声明这是一个eureka client,否则不会进行服务注册:
- package org.zero.eureka.client;
- import org.springframework.boot.SpringApplication;
- import org.springframework.boot.autoconfigure.SpringBootApplication;
- import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
- @SpringBootApplication
- @EnableDiscoveryClient
- public class ClientApplication {
- public static void main(String[] args) {
- SpringApplication.run(ClientApplication.class, args);
- }
- }
接着就是在application.yml配置文件中,配置注册中心即eureka server的地址,以及项目的名称和启动端口号。如下:
- eureka:
- client:
- service-url:
- defaultZone: http://localhost:8761/eureka/
- spring:
- application:
- name: eureka-client
- server:
- port: 9088
完成以上配置后,即可启动项目。但是我这里启动项目的时候失败了,控制台输出如下警告信息:
Invocation of destroy method failed on bean with name 'scopedTarget.eurekaClient': org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'eurekaInstanceConfigBean': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
这是因为client里不包含Tomcat的依赖,所以Spring容器无法创建一些实例,从而导致项目无法启动,只需在pom.xml文件中,加上web依赖即可:
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-web</artifactId>
- </dependency>
项目启动成功后,可以在eureka server的信息面板中查看到已注册的实例信息,如下:
EurekaClient项目启动报错Invocation of destroy method failed on bean with name 'scopedTarget.eurekaClient': org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'e的更多相关文章
- 【spring boot】使用注解@ConfigurationProperties读取配置文件时候 报错 org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'rocketmqAutoConfiguration': Unsatisfied dependenc
如题,配置文件如下: #注册中心配置 eureka: instance: instanceId: ${spring.application.name}:${random.int} hostname: ...
- 报错org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [bean.xml]
报这种错的原因基本上是applicationContext.xml文件中bean配置错误,错误如下: org.springframework.beans.factory.BeanCreationExc ...
- 【报错】org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webSocketHandlerMapping' defined in class path resource
环境:maven+eclipse+jdk1.8 [tomcat使用的是maven自带的插件,实质原因就是出在tomcat版本问题] 背景:在进行SSM集成WebSocket的时候,项目启动报org.s ...
- Spring AOP 报错org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'XXXXXX' defined in class path resource..........
完整报错如下: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'befo ...
- ssh整合报错严重: Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxx'
错误描述:eclipse整合ssh的时候 报不能创建名字为xxx的对象 信息: Destroying singletons in org.springframework.beans.factory.s ...
- org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [bean.xml]: Invocation of init method failed; nested exception is
在复制xml文件进行修改的时候,我经常将不小心对原文件进行修改,而导致创建bean出错.报错如下所示: Exception sending context initialized event to l ...
- aused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method fai
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'roleDaoImpl' ...
- springcloud报错:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'armeriaServer' defined in class path resource
spring boot配置zipkin 无法启动 加入 Zipkin Server 由于需要收集 Spring Cloud 系统的跟踪信息,以便及时地发现系统中出现的延迟升高问题并找出系统性能瓶颈的根 ...
- 报错!!!!!!!!!!!org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSessionRepositoryFilter' is defined
报错!!!!!!!!!!! 因用maven项目不是很熟练,经常在Maven转Web项目(为什么要转web项目?因为要在tomcat中跑起来.maven项目好像是可以直接部署到tomcat的,或集成to ...
随机推荐
- deb包转化为rpm包
deb文件格式本是ubuntu的安装文件,那么我想要在fedora中安装,需要把deb格式转化成rpm格式,我们用skype举例: 1.下载转换工具alien_8.78.tar.gz 2.deb转化成 ...
- SpringCloud学习笔记:SpringCloud简介(1)
1. 微服务 微服务具有的特点: ◊ 按照业务划分服务 ◊ 每个微服务都有独立的基础组件,如:数据库.缓存等,且运行在独立的进程中: ◊ 微服务之间的通讯通过HTTP协议或者消息组件,具有容错能力: ...
- 解决SpringSecurity阻止ajax的POST和PUT请求,导致403Forbidden的问题
前言: 最近在整合springboot+springsecurity,在PUT请求的时候出现了403的问题,这里记录一下解决的过程 到Spring的官网去查查SpringSecurity的参考手册看看 ...
- Javascript初识之流程控制、函数和内置对象
一.JS流程控制 1. 1.if else var age = 19; if (age > 18){ console.log("成年了"); }else { console. ...
- 初识服务器和Linux
一.什么是计算机 1.介绍 一说到计算机,我们首先想到的就是电脑,没错,电脑就是计算机,但是计算机不只是电脑. 所谓的电脑就是一种计算机,而计算机其实是:接收使用者输入的指令与资料,经中央处理器的数学 ...
- [HDU5969] 最大的位或
题目类型:位运算 传送门:>Here< 题意:给出\(l\)和\(r\),求最大的\(x|y\),其中\(x,y\)在\([l,r]\)范围内 解题思路 首先让我想到了前面那题\(Bits ...
- luogu P2617 Dynamic Rankings && bzoj 1901 (带修改区间第k大)
链接:https://www.luogu.org/problemnew/show/P2617 思路: 如果直接在主席树上修改的话,每次修改都会对后面所有的树造成影响,一次修改的复杂度就会变成 : n* ...
- 指数型生成函数 及 多项式求ln
指数型生成函数 我们知道普通型生成函数解决的是组合问题,而指数型生成函数解决的是排列问题 对于数列\(\{a_n\}\),我们定义其指数型生成函数为 \[G(x) = a_0 + a_1x + a_2 ...
- java jdbc ResultSet结果通过java反射赋值给java对象
在不整合框架的情况下,使用jdbc从数据库读取数据时都得一个个的get和set,不仅累代码还显得不简洁,所以利用java的反射机制写了一个工具类,这样用jdbc从数据库拿数据的时候就不用那么麻烦了. ...
- [BJOI2019] 光线
看起来很麻烦,做起来并不难的题 以下设:$a_i=\frac{a_i}{100},b_i=\frac{b_i}{100}$ 显然,如果$b_i=0$的话,直接求$\Pi a_i$就是答案. 解决反射问 ...