Error creating bean with name scopedtarget.eurekaclient defined in class path resource

org.springframework.context.ApplicationContextException: Failed to start bean 'org.springframework.cloud.netflix.eureka.EurekaDiscoveryClientConfiguration'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.eurekaClient' defined in class path resource [org/springframework/cloud/netflix/eureka/EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.netflix.discovery.EurekaClient]: Factory method 'eurekaClient' threw exception; nested exception is java.lang.RuntimeException: Failed to initialize DiscoveryClient!

springcloud启动的时候报这个错误。

解决增加jersey jar

<dependency> <groupId>org.glassfish.jersey.core</groupId> <artifactId>jersey-server</artifactId> <version>2.25.1</version> </dependency>

spring boot是1.3.0或者是1.5.13这两个版本
--------------------- 
转载原文:https://blog.csdn.net/badyting/article/details/72822660 

Disconnected from the target VM, address: '127.0.0.1:51233', transport: 'socket'

Eureka Client Use

Use IDEA Create a Spring Initializr project , When checking the module, you need to select Eureka Discovery, as follows :

Error creating bean with name scopedtarget.eurekaclient defined in class path resource

project-generated pom.xml The contents of the document are as follows :

  1. <?xml version="1.0" encoding="UTF-8"?>

  2. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

  3. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  4. <modelVersion>4.0.0</modelVersion>

  5. <groupId>org.zero.eureka</groupId>

  6. <artifactId>client</artifactId>

  7. <version>0.0.1-SNAPSHOT</version>

  8. <packaging>jar</packaging>

  9. <name>client</name>

  10. <description>Demo project for Spring Boot</description>

  11. <parent>

  12. <groupId>org.springframework.boot</groupId>

  13. <artifactId>spring-boot-starter-parent</artifactId>

  14. <version>2.0.4.RELEASE</version>

  15. <relativePath/> <!-- lookup parent from repository -->

  16. </parent>

  17. <properties>

  18. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

  19. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

  20. <java.version>1.8</java.version>

  21. <spring-cloud.version>Finchley.SR1</spring-cloud.version>

  22. </properties>

  23. <dependencies>

  24. <dependency>

  25. <groupId>org.springframework.cloud</groupId>

  26. <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>

  27. </dependency>

  28. <dependency>

  29. <groupId>org.springframework.boot</groupId>

  30. <artifactId>spring-boot-starter-test</artifactId>

  31. <scope>test</scope>

  32. </dependency>

  33. </dependencies>

  34. <dependencyManagement>

  35. <dependencies>

  36. <dependency>

  37. <groupId>org.springframework.cloud</groupId>

  38. <artifactId>spring-cloud-dependencies</artifactId>

  39. <version>${spring-cloud.version}</version> 

  40. <scope>import</scope>

  41. </dependency>

  42. </dependencies>

  43. </dependencyManagement>

  44. <build>

  45. <plugins>

  46. <plugin>

  47. <groupId>org.springframework.boot</groupId>

  48. <artifactId>spring-boot-maven-plugin</artifactId>

  49. </plugin>

  50. </plugins>

  51. </build> 

After all the project dependencies are loaded , Add... To the startup class @EnableDiscoveryClient, Declare that this is a eureka client, Otherwise, there will be no service registration :

  1. package org.zero.eureka.client;

  2. import org.springframework.boot.SpringApplication;

  3. import org.springframework.boot.autoconfigure.SpringBootApplication;

  4. import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

  5. public class ClientApplication {

  6. public static void main(String[] args) {

  7. SpringApplication.run(ClientApplication.class, args);

  8. }

And then there was application.yml In profile , The configuration registry is eureka server The address of , And the name and boot port number of the project . as follows :

  1. eureka: 

  2. service-url:

  3. defaultZone: http://localhost:8761/eureka/

  4. spring:

  5. application:

  6. name: eureka-client

  7. server:

  8. port: 9088

After completing the above configuration , Start the project . But I failed when I started the project here , The console outputs the following warning message :

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!)

This is because client It doesn't contain Tomcat Dependence , therefore Spring The container was unable to create some instances , As a result, the project cannot be started , Just in pom.xml In file , add web Rely on it :

  1. <dependency>

  2. <groupId>org.springframework.boot</groupId>

  3. <artifactId>spring-boot-starter-web</artifactId>

  4. </dependency>

After the project starts successfully , Can be in eureka server View the registered instance information in the information panel of , as follows :

Error creating bean with name scopedtarget.eurekaclient defined in class path resource

  1. 【spring boot】 Using annotations @ConfigurationProperties When reading the configuration file Report errors org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name &#39;rocketmqAutoConfiguration&#39;: Unsatisfied dependenc

    As the title , The configuration file is as follows : # Registry configuration eureka: instance: instanceId: ${spring.application.name}:${random.int} hostname: ...

  2. Report errors org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;sessionFactory&#39; defined in class path resource [bean.xml]

    The reason for this kind of mistake is basically applicationContext.xml In file bean Configuration error , Error is as follows : org.springframework.beans.factory.BeanCreationExc ...

  3. 【 Report errors 】org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;webSocketHandlerMapping&#39; defined in class path resource

    Environmental Science :maven+eclipse+jdk1.8 [tomcat It uses maven Built-in plug-ins , The real reason is that tomcat Version of the problem ] background : It's going on SSM Integrate WebSocket When , Project initiation report org.s ...

  4. Spring AOP Report errors org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;XXXXXX&#39; defined in class path resource..........

    The complete error report is as follows : org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'befo ...

  5. ssh Integration error is serious : Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;xxx&#39;

    Error description :eclipse Integrate ssh When Newspaper cannot be created with the name xxx The object of Information : Destroying singletons in org.springframework.beans.factory.s ...

  6. org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;sessionFactory&#39; defined in class path resource [bean.xml]: Invocation of init method failed; nested exception is

    Copying xml When the file is modified , I often change the original file by accident , And lead to the creation of bean error . The error is reported as follows : Exception sending context initialized event to l ...

  7. aused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;sessionFactory&#39; defined in class path resource [applicationContext.xml]: Invocation of init method fai

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'roleDaoImpl' ...

  8. Report errors !!!!!!!!!!!org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named &#39;springSessionRepositoryFilter&#39; is defined

    Report errors !!!!!!!!!!! For use maven The project is not very skilled , Often in Maven turn Web project ( Why do you want to turn web project ? Because in tomcat Run up .maven It seems that the project can be deployed directly to tomcat Of , Or integration to ...

  9. Invocation of destroy method failed on bean with name ‘XXXX’

    The problem of project startup error reporting :Invocation of destroy method failed on bean with name 'scopedTarget.eurekaClient': org.spri ...

Random recommendation

  1. unity It's a homemade glass beer bottle shader

    The customer's requirements are as follows step : 1. Analyze the effect of glass bottle The effect is as follows : highlights , Like subsurface scattering ( The inner layer is transparent and the outer layer is dull ), The outer white outlines . highlights :unity Internal smoothness parameters are provided , The smoother, the more obvious the highlight effect is , The material of beer bottle belongs to ...

  2. POJ 2991–Crane【 Line segment tree + The geometric 】

    The question : Think of each arm as a vector , Then the position of the manipulator is exactly the sum of the arm vectors . Rotate a joint , It's actually rotating all the arm vectors from the joint to the manipulator . Because there are so many arms , It takes time for each vector to do the same rotation . Now you can think of using line segments ...

  3. DNS Domain name resolution

    It used to be DNSPOD.CN Parsing , No problem . Because I want to do server analysis according to different countries ( The European , Asia , The United States ) And then go to DNSPOD.com It's divided by country . But the reaction from Europe , I can't visit the website on and off every day . ...

  4. ASP.NET There is no magic ——ASP.NET MVC filter (Filter)

    The last article introduced the use of Authorize Feature implementation ASP.NET MVC Targeted at Controller perhaps Action Authorization function of , In fact, this feature is MVC Part of the function , It's called a filter (Filter), It's a kind of face ...

  5. Target file removal header At the beginning of a line # Number

    Please follow the steps below to configure : -->  open session Of Config Object tab , And edit Custom Properties Options -->  edit Custom Properties project ...

  6. Lunch War with the Donkey CSU - 2084

    Jingze is a big figure in California State University for his stubbornness. Because of his new failu ...

  7. Applet canvas Realize picture preview , pictures saving

    wxml Code : <view class="result-page"> <canvas bindtap="previewImage" canv ...

  8. kaggle Summary of the Titanic problem

    Learning machine learning for so long , It's the first time to really solve a practical problem with the method of machine learning , Explore step by step , Although the final result is not very accurate , Only to achieve 0.78647, But it's a lot to gain , In order to prevent my memory bug from going to the brain in the future , I decided to take notes . ...

  9. laravel Some function meanings of database query ( unfinished )

    ->all() Query all the information in the database , An object form returns $rows=UserModel::all(); ->get() The execution function of the query ,->toArray() What you want to query is to convert the data set into a number ...

  10. JNI A simple example of

    The operating system used in this example MacOS, 64 position JVM. JNI The steps are as follows : To write Java Code , And let us know native Method : public class HelloJni { public native v ...