首先说原因:
1.电脑没有主机名或中文的主机名,导致的读到了中文主机名不能识别。
2.多个网卡问题。
过程:
Passed in hostname is blank, not setting it,启动的时候报错找不到主机名。错误信息如下:
[2022-06-28 14:04:55.547] INFO [registry,,,] 18816 --- [main] trationDelegate$BeanPostProcessorChecker 335: Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[2022-06-28 14:04:56.532] INFO [registry,,,] 18816 --- [main] o.s.boot.SpringApplication 655: The following profiles are active: dev
[2022-06-28 14:04:57.889] WARN [registry,,,] 18816 --- [main] o.s.boot.actuate.endpoint.EndpointId 155: Endpoint ID 'service-registry' contains invalid characters, please migrate to a valid format.
[2022-06-28 14:04:58.137] INFO [registry,,,] 18816 --- [main] o.s.cloud.context.scope.GenericScope 295: BeanFactory id=1d7c0d44-51db-3842-b437-52cbb60debd7
[2022-06-28 14:04:58.344] INFO [registry,,,] 18816 --- [main] trationDelegate$BeanPostProcessorChecker 335: Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
[2022-06-28 14:04:58.800] INFO [registry,,,] 18816 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer 91: Tomcat initialized with port(s): 8085 (http)
[2022-06-28 14:04:58.816] INFO [registry,,,] 18816 --- [main] org.apache.juli.logging.DirectJDKLog 173: Starting service [Tomcat]
[2022-06-28 14:04:58.817] INFO [registry,,,] 18816 --- [main] org.apache.juli.logging.DirectJDKLog 173: Starting Servlet engine: [Apache Tomcat/9.0.38]
[2022-06-28 14:04:58.989] INFO [registry,,,] 18816 --- [main] org.apache.juli.logging.DirectJDKLog 173: Initializing Spring embedded WebApplicationContext
[2022-06-28 14:04:58.989] INFO [registry,,,] 18816 --- [main] w.s.c.ServletWebServerApplicationContext 283: Root WebApplicationContext: initialization completed in 2435 ms
[2022-06-28 14:04:59.540] WARN [registry,,,] 18816 --- [main] c.n.c.sources.URLConfigurationSource 121: No URLs will be polled as dynamic configuration sources.
[2022-06-28 14:04:59.541] INFO [registry,,,] 18816 --- [main] c.n.c.sources.URLConfigurationSource 122: To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
[2022-06-28 14:04:59.557] INFO [registry,,,] 18816 --- [main] c.netflix.config.DynamicPropertyFactory 281: DynamicPropertyFactory is initialized with configuration sources: com.netflix.config.ConcurrentCompositeConfiguration@273a5a8a
[2022-06-28 14:04:59.726] INFO [registry,,,] 18816 --- [main] c.s.j.s.i.a.WebApplicationImpl 815: Initiating Jersey application, version 'Jersey: 1.19.1 03/11/2016 02:08 PM'
[2022-06-28 14:04:59.802] INFO [registry,,,] 18816 --- [main] c.n.d.provider.DiscoveryJerseyProvider 70: Using JSON encoding codec LegacyJacksonJson
[2022-06-28 14:04:59.804] INFO [registry,,,] 18816 --- [main] c.n.d.provider.DiscoveryJerseyProvider 71: Using JSON decoding codec LegacyJacksonJson
[2022-06-28 14:04:59.943] INFO [registry,,,] 18816 --- [main] c.n.d.provider.DiscoveryJerseyProvider 80: Using XML encoding codec XStreamXml
[2022-06-28 14:04:59.944] INFO [registry,,,] 18816 --- [main] c.n.d.provider.DiscoveryJerseyProvider 81: Using XML decoding codec XStreamXml
[2022-06-28 14:05:00.651] INFO [registry,,,] 18816 --- [main] o.s.s.web.DefaultSecurityFilterChain 43: Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@6e8f2094, org.springframework.security.web.context.SecurityContextPersistenceFilter@66d3b881, org.springframework.security.web.header.HeaderWriterFilter@1b409a79, org.springframework.security.web.authentication.logout.LogoutFilter@1f7e52d1, org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter@8077c97, org.springframework.security.web.authentication.ui.DefaultLoginPageGeneratingFilter@28554ac8, org.springframework.security.web.authentication.ui.DefaultLogoutPageGeneratingFilter@1753475d, org.springframework.security.web.authentication.www.BasicAuthenticationFilter@3a0896b3, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@762a10b6, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@539316bb, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@d108406, org.springframework.security.web.session.SessionManagementFilter@1cba0321, org.springframework.security.web.access.ExceptionTranslationFilter@2dcd0e41, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@7b377a53]
[2022-06-28 14:05:00.669] WARN [registry,,,] 18816 --- [main] c.n.c.sources.URLConfigurationSource 121: No URLs will be polled as dynamic configuration sources.
[2022-06-28 14:05:00.669] INFO [registry,,,] 18816 --- [main] c.n.c.sources.URLConfigurationSource 122: To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
[2022-06-28 14:05:00.832] INFO [registry,,,] 18816 --- [main] o.s.s.c.ExecutorConfigurationSupport 181: Initializing ExecutorService 'applicationTaskExecutor'
[2022-06-28 14:05:01.763] WARN [registry,,,] 18816 --- [main] c.netflix.appinfo.InstanceInfo$Builder 457: Passed in hostname is blank, not setting it
[2022-06-28 14:05:01.766] WARN [registry,,,] 18816 --- [main] o.s.c.s.AbstractApplicationContext 559: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'serviceController' defined in class path resource [at/twinformatics/eureka/adapter/consul/EurekaConsulAdapterConfig.class]: Unsatisfied dependency expressed through method 'serviceController' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'registrationService' defined in class path resource [at/twinformatics/eureka/adapter/consul/EurekaConsulAdapterConfig.class]: Unsatisfied dependency expressed through method 'registrationService' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'registrationEventInstanceRegistry' defined in class path resource [at/twinformatics/eureka/adapter/consul/EurekaConsulAdapterConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [at.twinformatics.eureka.adapter.consul.service.RegistrationEventInstanceRegistry]: Factory method 'registrationEventInstanceRegistry' threw exception; 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.IllegalStateException: Failed to unwrap proxied object
[2022-06-28 14:05:01.767] INFO [registry,,,] 18816 --- [main] o.s.s.c.ExecutorConfigurationSupport 218: Shutting down ExecutorService 'applicationTaskExecutor'
[2022-06-28 14:05:01.770] INFO [registry,,,] 18816 --- [main] org.apache.juli.logging.DirectJDKLog 173: Stopping service [Tomcat]
[2022-06-28 14:05:01.792] INFO [registry,,,] 18816 --- [main] ConditionEvaluationReportLoggingListener 136:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[2022-06-28 14:05:01.804] ERROR [registry,,,] 18816 --- [main] o.s.boot.SpringApplication 826: Application run failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'serviceController' defined in class path resource [at/twinformatics/eureka/adapter/consul/EurekaConsulAdapterConfig.class]: Unsatisfied dependency expressed through method 'serviceController' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'registrationService' defined in class path resource [at/twinformatics/eureka/adapter/consul/EurekaConsulAdapterConfig.class]: Unsatisfied dependency expressed through method 'registrationService' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'registrationEventInstanceRegistry' defined in class path resource [at/twinformatics/eureka/adapter/consul/EurekaConsulAdapterConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [at.twinformatics.eureka.adapter.consul.service.RegistrationEventInstanceRegistry]: Factory method 'registrationEventInstanceRegistry' threw exception; 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.IllegalStateException: Failed to unwrap proxied object
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:797)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:538)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1336)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1176)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:556)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:516)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:324)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:322)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:897)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at com.szkingdom.koca.registry.KocaRegisterServerApplication.main(KocaRegisterServerApplication.java:38)
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'registrationService' defined in class path resource [at/twinformatics/eureka/adapter/consul/EurekaConsulAdapterConfig.class]: Unsatisfied dependency expressed through method 'registrationService' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'registrationEventInstanceRegistry' defined in class path resource [at/twinformatics/eureka/adapter/consul/EurekaConsulAdapterConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [at.twinformatics.eureka.adapter.consul.service.RegistrationEventInstanceRegistry]: Factory method 'registrationEventInstanceRegistry' threw exception; 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.IllegalStateException: Failed to unwrap proxied object
因为在注册中心启动需要会获取到电脑名称,构建服务端路径,发布服务,客户端找这个路径。
一般来说每台电脑都会有主机名,这里获取不到,难道这个hostname是ip地址?
进入cmd输入ipconfig后,发现有好几个网卡的ip信息,有无线局域网的、VMware的两个、windows11的wsl网卡,想着是不是因为多个网卡问题而导致的,禁用其他网络适配器后,启动还是一样的错误。
然后在去看电脑的主机名,发现是中文的,改成英文后启动成功。