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

Eureka Client的使用

使用IDEA创建一个Spring Initializr项目,在勾选模块的时候需要选择Eureka Discovery,如下:

项目生成的pom.xml文件内容如下:

  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.   
  6.  <groupId>org.zero.eureka</groupId>
  7.  <artifactId>client</artifactId>
  8.  <version>0.0.1-SNAPSHOT</version>
  9.  <packaging>jar</packaging>
  10.  
  11.  <name>client</name>
  12.  <description>Demo project for Spring Boot</description>
  13.  
  14.  <parent>
  15.  <groupId>org.springframework.boot</groupId>
  16.  <artifactId>spring-boot-starter-parent</artifactId>
  17.  <version>2.0.4.RELEASE</version>
  18.  <relativePath/> <!-- lookup parent from repository -->
  19.  </parent>
  20.   
  21.  <properties>
  22.  <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  23.  <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  24.  <java.version>1.8</java.version>
  25.  <spring-cloud.version>Finchley.SR1</spring-cloud.version>
  26.  </properties>
  27.  
  28.  <dependencies>
  29.  <dependency>
  30.  <groupId>org.springframework.cloud</groupId>
  31.  <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
  32.  </dependency>
  33.   
  34.  <dependency>
  35.  <groupId>org.springframework.boot</groupId>
  36.  <artifactId>spring-boot-starter-test</artifactId>
  37.  <scope>test</scope>
  38.  </dependency>
  39.  </dependencies>
  40.   
  41.  <dependencyManagement>
  42.  <dependencies>
  43.  <dependency>
  44.  <groupId>org.springframework.cloud</groupId>
  45.  <artifactId>spring-cloud-dependencies</artifactId>
  46.  <version>${spring-cloud.version}</version> 
  47. <type>pom</type>
  48.  <scope>import</scope>
  49.  </dependency>
  50.  </dependencies>
  51.  </dependencyManagement>
  52.   
  53.  <build>
  54.  <plugins>
  55.  <plugin>
  56.  <groupId>org.springframework.boot</groupId>
  57.  <artifactId>spring-boot-maven-plugin</artifactId>
  58.  </plugin>
  59.  </plugins>
  60.  </build> 
  61. </project>

项目的依赖都加载完成后,在启动类中加上@EnableDiscoveryClient,声明这是一个eureka client,否则不会进行服务注册:

  1. package org.zero.eureka.client;
  2.  
  3.  import org.springframework.boot.SpringApplication;
  4.  import org.springframework.boot.autoconfigure.SpringBootApplication;
  5.  import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
  6.   
  7. @SpringBootApplication
  8. @EnableDiscoveryClient
  9.  public class ClientApplication {
  10.  
  11.  public static void main(String[] args) {
  12.  SpringApplication.run(ClientApplication.class, args);
  13.  }
  14. }

接着就是在application.yml配置文件中,配置注册中心即eureka server的地址,以及项目的名称和启动端口号。如下:

  1.  eureka: 
  2.       client:
  3.    service-url:
  4.            defaultZone: http://localhost:8761/eureka/
  5.  spring:
  6.    application:
  7.      name: eureka-client
  8.  server:
  9.    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依赖即可:

  1.  <dependency>
  2.  <groupId>org.springframework.boot</groupId>
  3.  <artifactId>spring-boot-starter-web</artifactId>
  4.  </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的更多相关文章

  1. 【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: ...

  2. 报错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 ...

  3. 【报错】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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 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' ...

  8. springcloud报错:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'armeriaServer' defined in class path resource

    spring boot配置zipkin 无法启动 加入 Zipkin Server 由于需要收集 Spring Cloud 系统的跟踪信息,以便及时地发现系统中出现的延迟升高问题并找出系统性能瓶颈的根 ...

  9. 报错!!!!!!!!!!!org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'springSessionRepositoryFilter' is defined

    报错!!!!!!!!!!! 因用maven项目不是很熟练,经常在Maven转Web项目(为什么要转web项目?因为要在tomcat中跑起来.maven项目好像是可以直接部署到tomcat的,或集成to ...

随机推荐

  1. spring boot 表单验证

    1 设置某个字段的取值范围 1.1 取值范围验证:@Min,@Max ① 实例类的属性添加注解@Min ② Controller中传入参数使用@Valid注解 1.2 不能为空验证:@NotNull ...

  2. 通过FactoryBean配置Bean

    这是配置Bean的第三种方式,FactoryBean是Spring为我们提供的,我们先来看看源码: 第一个方法:public abstract T getObject() throws Excepti ...

  3. python xlwt模块生成excel文件并写入数据 xlrd读取数据

    python中一般使用 xlwt (excel write)来生成Excel文件(可以控制单元格格式),用 xlrd 来读取Excel文件,用xlrd读取excel是不能对其进行操作的. 1.xlrd ...

  4. input按钮使用方法

  5. Hive 执行作业时报错 [ Diagnostics: File file:/ *** reduce.xml does not exist FileNotFoundException: File file:/ ]

    2019-03-10 本篇文章旨在阐述本人在某一特定情况下遇到 Hive 执行 MapReduce 作业的问题的探索过程与解决方案.不对文章的完全.绝对正确性负责. 解决方案 Hive 的配置文件  ...

  6. Android查看联系人简单记录

    简单实现打印联系人信息,可以作为插入联系人的基础和主要代码块,作为个人记录的小逻辑 package com.lgqrlchinese.contactstest; import android.Mani ...

  7. ovs-qos配置

    QoS配置 在许多网络场景中,都需要根据需求对网络流量部署服务质量(QoS)保障策略,比如限制指定主机的最大接入带宽等需求.本节将介绍如何在OVS上添加队列,并完成数据的入队操作,从而完成QoS策略部 ...

  8. java替换ascii表字符

    如下: //处理特殊字符 public String dealSpecialXml(String xml){ String result = ""; //result = xml. ...

  9. Luogu_1944 最长括号匹配

    题目链接 动态规划的方式: 1. 上一个括号或者上一段合法序列的前一个括号和当前位置形成 (A),[A] 型合法序列: 2. 该位置所在的当前合法序列和之前的某一段与其相邻的序列组成 AB 型合法序列 ...

  10. <六>企业级开源仓库nexus3实战应用–使用nexus3配置yum私有仓库

    一两个星期之前,你如果在我跟前说起私服的事情,我大概会绕着你走,因为我对这个东西真的一窍不通.事实上也正如此,开发同学曾不止一次的跟我说公司的私服版本太旧了,许多新的依赖编译之后不会从远程仓库自动缓存 ...