1. 程式人生 > >spring cloud boot 啟動報錯java.lang.IllegalStateException: Service id not legal hostname (/user-service)

spring cloud boot 啟動報錯java.lang.IllegalStateException: Service id not legal hostname (/user-service)

spring cloud專案啟動報錯,記錄如下:

java.lang.IllegalStateException: Service id not legal hostname (/user-service)
	at org.springframework.util.Assert.state(Assert.java:70) ~[spring-core-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.cloud.netflix.feign.FeignClientsRegistrar.getName(FeignClientsRegistrar.java:231) ~[spring-cloud-netflix-core-1.2.4.RELEASE.jar:1.2.4.RELEASE]
	at org.springframework.cloud.netflix.feign.FeignClientsRegistrar.registerFeignClient(FeignClientsRegistrar.java:177) ~[spring-cloud-netflix-core-1.2.4.RELEASE.jar:1.2.4.RELEASE]
	at org.springframework.cloud.netflix.feign.FeignClientsRegistrar.registerFeignClients(FeignClientsRegistrar.java:163) ~[spring-cloud-netflix-core-1.2.4.RELEASE.jar:1.2.4.RELEASE]
	at org.springframework.cloud.netflix.feign.FeignClientsRegistrar.registerBeanDefinitions(FeignClientsRegistrar.java:88) ~[spring-cloud-netflix-core-1.2.4.RELEASE.jar:1.2.4.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsFromRegistrars(ConfigurationClassBeanDefinitionReader.java:354) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:143) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:116) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:320) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:270) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE]
	at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE]
	at com.sinotrans.ms.SinotransOrgServiceApplication.main(SinotransOrgServiceApplication.java:24) [classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_60]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_60]
	at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_60]
	at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.5.3.RELEASE.jar:1.5.3.RELEASE]

2017-06-05 16:55:43.362  INFO 9440 --- [  restartedMain] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot
[email protected]
257b06a8: startup date [Mon Jun 05 16:55:41 CST 2017]; parent: org.spring[email protected]54bbfc79 2017-06-05 16:55:43.363 WARN 9440 --- [ restartedMain] ationConfigEmbeddedWebApplicationContext : Exception thrown from LifecycleProcessor on context close java.lang.IllegalStateException: LifecycleProcessor not initialized - call 'refresh' before invoking lifecycle methods via the context: org.springframework.boot
[email protected]
257b06a8: startup date [Mon Jun 05 16:55:41 CST 2017]; parent: org.spring[email protected]54bbfc79 at org.springframework.context.support.AbstractApplicationContext.getLifecycleProcessor(AbstractApplicationContext.java:417) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1002) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:961) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:794) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:325) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE] at com.sinotrans.ms.SinotransOrgServiceApplication.main(SinotransOrgServiceApplication.java:24) [classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_60] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_60] at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_60] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.5.3.RELEASE.jar:1.5.3.RELEASE] 2017-06-05 16:55:43.365 ERROR 9440 --- [ restartedMain] o.s.b.f.s.DefaultListableBeanFactory : Destroy method on bean with name 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory' threw an exception java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot
[email protected]
257b06a8: startup date [Mon Jun 05 16:55:41 CST 2017]; parent: org.spring[email protected]54bbfc79 at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:404) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:97) ~[spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253) ~[spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578) [spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554) [spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961) [spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523) [spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968) [spring-beans-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1033) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1009) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:961) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:794) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:325) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.3.RELEASE.jar:1.5.3.RELEASE] at com.sinotrans.ms.SinotransOrgServiceApplication.main(SinotransOrgServiceApplication.java:24) [classes/:na] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_60] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_60] at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_60] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-1.5.3.RELEASE.jar:1.5.3.RELEASE]

目前只是使用了feign來訪問user-service的微服務,報此錯誤,判斷是配置的錯誤,但是依舊 沒解決;

最後詢問了周立大神,原來哭

@FeignClient("/user-service")
public interface ISinotransOrgRemoteServer {
	
	
	/*@RequestMapping(value="/InternalUser/getByOrgId/{orgId}",method=RequestMethod.GET)
	SinotransOrg findDetailsByOrgId(@PathVariable("orgId") Integer orgId);  */
	
	@RequestMapping(value="/InternalUser/getByOrgId/{orgId}",method=RequestMethod.GET)
	public List<InternalUser> getUsersByOrgId (@PathVariable("orgId") Integer orgId);
}

類上註解中多個 /,真是汗顏啊,去掉就好了。
@FeignClient("user-service")
public interface ISinotransOrgRemoteServer {
	
	
	/*@RequestMapping(value="/InternalUser/getByOrgId/{orgId}",method=RequestMethod.GET)
	SinotransOrg findDetailsByOrgId(@PathVariable("orgId") Integer orgId);  */
	
	@RequestMapping(value="/InternalUser/getByOrgId/{orgId}",method=RequestMethod.GET)
	public List<InternalUser> getUsersByOrgId (@PathVariable("orgId") Integer orgId);
}

感謝周神!

相關推薦

spring cloud boot 啟動java.lang.IllegalStateException: Service id not legal hostname (/user-service)

spring cloud專案啟動報錯,記錄如下: java.lang.IllegalStateException: Service id not legal hostname (/user-service) at org.springframework.util.As

解決spring boot啟動java.lang.NoClassDefFoundError: ch/qos/logback/classic/Level

blog nbsp java In idea AS level def sdn 解決spring boot啟動報錯java.lang.NoClassDefFoundError: ch/qos/logback/classic/Level 學習了:https://blog.cs

Spring-Boot啟動java.lang.NoClassDefFoundError: ch/qos/logback/classic/turbo/TurboFilter

今天搭建專案的時候啟動報錯,java.lang.NoClassDefFoundError: ch/qos/logback/classic/turbo/TurboFilter 具體錯誤如下: 2018-09-15 16:06:14,588 main ERROR append

web專案啟動:java.lang.IllegalStateException

java.lang.IllegalStateException: Illegal access: this web application instance has been stopped already. Could not load []. The following stack tra

springboot配置aop,啟動java.lang.IllegalStateException:Expected raw type form 這類問題

springboot配置aop,啟動報錯java.lang.IllegalStateException: Expected raw type form of org.springframework.web.servlet.handler.AbstractHandlerMethodMapp

springboot啟動java.lang.IllegalStateException: ApplicationEventMulticaster not initialized

這個錯誤是比較奇葩,當時我和同事都同時從svn上下載的最新版本,他能成功開啟application,但是我每次開啟都直接崩掉,我也是傻,沒好好想想報錯的位置,當時排除了程式碼的各種問題,又一遍一遍重啟idea,都沒有效果. 第二天來公司之後,冷靜下來細細思考,發現是一開始啟

ActiveMQ啟動:java.lang.IllegalStateException: LifecycleProcessor not initialized

一、問題描述 一啟動ActiveMQ就報錯: ERROR: java.lang.RuntimeException: Failed to execute start task. Reason: java.lang.IllegalStateException: BeanFa

Spring Boot,IntelliJ IDEA,JSP,啟動java.lang.NoClassDefFoundError: javax/servlet/ServletContext

問題描述 今天試了下Idea這個工具,發現它的編碼功能十分強大,在啟動Spring Boot專案時,發現報錯: java.lang.NoClassDefFoundError: javax/servlet/ServletContext at java.lang.

Spring boot 啟動 'elasticsearchTemplate' that could not be found.

Spring boot 啟動報錯 (a)異常資訊 Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 201

springboot 啟動 java.lang.ClassNotFoundException: javax.servlet.ServletContext

Intellij IDEA啟動springboot +maven專案報錯: ==============================================================================================================

springboot 啟動 java.lang.ClassNotFoundException: javax.servlet.ServletContext

Intellij IDEA啟動springboot +maven專案報錯: ===================================================================================================

maven項目 啟動:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

mave .cn maven依賴 dep found ext trie rec sse 轉自:https://www.cnblogs.com/gugnv/p/4136819.html tomcat在發布項目的時候沒有同時發布maven依賴所添加的jar包,所以找不到解決方法

hive啟動 java.lang.NoClassDefFoundError: org/apache/hadoop/hive/conf/HiveConf

bin/hive Exception in thread “main” java.lang.NoClassDefFoundError: org/apache/hadoop/hive/conf/HiveConf 這裡分享一種可能 到hadoop的etc/hadoo

Tomcat無法啟動,java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory

 參考資料:Tomcat無法啟動,報錯java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactoryhttp://archive.cnblogs.com/a/1941374/說明:在Tomcat7

DRP問題集結(一)-Tomcat無法啟動,java.lang.NoClassDefFoundError: org/apache/juli/logging/LogFactory

       最近一直在做DRP,也是我進入Java學習第一次以專案來實踐,遇到過很多問題,但總的來說與.net對照來看,它其他和C#非常相似,從開始java開始,對於語言的膽怯沒有了,真

maven web 專案中啟動 Java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet

主要原因是maven專案裡面的jar包嗎,沒有匯入到專案中 maven web 專案中啟動報錯  Java.lang.ClassNotFoundException: org.springframework.web.servlet.DispatcherServlet 錯誤描述: Java.lang.Cl

tomcat6啟動java.lang.ClassNotFoundException: 1catalina.org.apache.juli.FileHandler

             tomcat6啟動報錯 在apache-tomcat-6.0.26/logs/catalina.out日誌裡面報錯: java.lang.ClassNotFoundException: 1catalina.org.apache.juli.FileH

Tomcat啟動 java.lang.ClassNotFoundException: org.apache.jsp.index_jsp

這個問題是因為tomcat在啟動過程中jsp和servlet的jar包出了問題。 1. 如果你是用的maven,呢麼你就看看有沒有Jsp,Servlet,Jstl的包,沒有新增上,有的話重新add一下

關於啟動java.lang.NoClassDefFoundError: org/elasticsearch/plugins/NetworkPlugin的解決方案

用的elasticsearch是5.6.1的版本,spring-boot用的1.5.9,其中一個服務a依賴於另一個服務b,b添加了對elasticsearch和transport的依賴,程式碼如下:        <dependency>            &

Jetty9 啟動 java.lang.ClassNotFoundException: org.eclipse.jetty.util.component.Dumpable

java.lang.NoClassDefFoundError: org/eclipse/jetty/util/component/Dumpable     at java.lang.ClassLoader.defineClass1(Native Method)     at