2017-08-18 1 views
0

Lors de l'exécution du fichier config-client, l'erreur ci-dessous est détectée ..Simple chose directement à partir des guides du ressort ne fonctionne pas.Spring Cloud Config Service-Le client ne fonctionne pas

2017-08-18 13:44:31.194 ERROR 12548 --- [   main] o.s.boot.SpringApplication    : Application startup failed 

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'scopedTarget.restController': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'message' in value "${message}" 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1264) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE] 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE] 
    at org.sprin 

RestController 

@RefreshScope 
@org.springframework.web.bind.annotation.RestController 
public class RestController { 
    @Value("${message}") 
    private String message; 

    @RequestMapping("/message") 
    String getMessage() { 
     return this.message; 
    } 
} 

bootstrap.yml of config-client 
spring: 
    application: 
    name: config-client 
    cloud: 
    config: 
     uri: http://localhost:8888 
management: 
    security: 
    enabled: false 


application.yml of config-server 
spring: 
    application: 
    name: config-server 
    cloud: 
    config: 
     server: 
     git: 
      uri: https://github.com/config-properties 
server: 
    port: 8888 

journaux de service client config

Erreur lors du démarrage ApplicationContext. Pour afficher le rapport de configuration automatique, relancez votre application avec 'debug' activé. 18/08/2017 23: 13: 45.080 erreur 13812 --- [principale] osboot.SpringApplication: démarrage application a échoué

org.springframework.beans.factory.BeanCreationException: Erreur de création de haricot avec le nom « scopedTarget.restController ': L'injection des dépendances autowired a échoué; l'exception imbriquée est java.lang.IllegalArgumentException: Impossible de résoudre le 'message' de l'espace réservé en valeur "$ {message}" sur org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues ​​(AutowiredAnnotationBeanPostProcessor.java:372) ~ [print- beans-4.3.10.RELEASE.jar: 4.3.10.RELEASE] à org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean (AbstractAutowireCapableBeanFactory.java:1264) ~ [spring-beans-4.3.10.RELEASE. jar: 4.3.10.RELEASE] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean (AbstractAutowireCapableBeanFactory.java:553) ~ [spring-beans-4.3.10.RELEASE.jar: 4.3.10.RELEASE] à org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean (AbstractAutowireCapableBeanFactory.java:483) ~ [spring-beans-4.3.10.RELEASE .jar: 4.3.10.RELEASE] à org.springframework.beans.factory.support.AbstractBeanFactory $ 2.getObject (AbstractBeanFactory.java:345) ~ [spring-beans-4.3.10.RELEASE.jar: 4.3.10. DE PRESSE] à org.springframework.cloud.context.scope.GenericScope $ BeanLifecycleWrapper.getBean (GenericScope.java:359) ~ [ressort-cloud-context-1.2.3.RELEASE.jar: 1.2.3.RELEASE] à org.springframework.cloud.context.scope.GenericScope.get (GenericScope.java:176) ~ [spring-cloud-context-1.2.3.RELEASE.jar: 1.2.3.RELEASE] à org.springframework.beans. factory.support.AbstractBeanFactory.doGetBean (AbstractBeanFactory.java:340) ~ [spring-beans-4.3.10.RELEASE.jar: 4.3.10.RELEASE] à org.springframework.beans.factory.support.AbstractBeanFactory.getBean (AbstractBeanFactory.java:197) ~ [spring-beans-4.3.10.RELEASE.jar: 4.3.10.RELEASE] sur org.spring framework.context.support.AbstractApplicationContext.getBean (AbstractApplicationContext.java:1078) ~ [spring-context-4.3.10.RELEASE.jar: 4.3.10.RELEASE] à org.springframework.cloud.context.scope.refresh. RefreshScope.start (RefreshScope.java:121) ~ [spring-cloud-context-1.2.3.RELEASE.jar: 1.2.3.RELEASE] à sun.reflect.NativeMethodAccessorImpl.invoke0 (Méthode native) ~ [na: 1.8 .0_144] à sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:62) ~ [na: 1.8.0_144] à sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:43) ~ [na: 1.8.0_144 ] à java.lang.reflect.Method.invoke (Method.java:498) ~ [na: 1.8.0_144] à org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke (ApplicationListenerMethodAdapter.java:256) ~ [printemps -context-4.3.10.RELEASE .jar: 4.3.10.RELEASE] à org.springframework.context.event.ApplicationListenerMethodAdapter.processEvent (ApplicationListenerMethodAdapter.java:177) ~ [spring-context-4.3.10.RELEASE.jar: 4.3.10.RELEASE] à org.springframework.context.event.ApplicationListenerMethodAdapter.onApplicationEvent (ApplicationListenerMethodAdapter.java:140) ~ [spring-context-4.3.10.RELEASE.jar: 4.3.10.RELEASE] à org.springframework.context.event.SimpleApplicationEventMulticaster .invokeListener (SimpleApplicationEventMulticaster.java:167) ~ [spring-context-4.3.10.RELEASE.jar: 4.3.10.RELEASE] à org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent (SimpleApplicationEventMulticaster.java: 139) ~ [spring-context-4.3.10.RELEASE.jar: 4.3.10.RELEASE] à org.springframework.context.support.AbstractApplicationContext.publishEvent (AbstractApplicationContext.java:393) ~ [contexte-printemps- 4.3.10.RELEASE.jar: 4.3.10.RELEASE] à org.springframework.context.support.AbstractApplicationContext.publishEvent (AbstractApplicationContext.java:347) ~ [spring-context-4.3.10.RELEASE.jar: 4.3. 10.RELEASE] à org.springframework.context.support.AbstractApplicationContext.finishRefresh (AbstractApplicationContext.java:883) ~ [spring-context-4.3.10.RELEASE.jar: 4.3.10.RELEASE] à org.springframework. boot.context.embedded.EmbeddedWebApplicationContext.finishRefresh (EmbeddedWebApplicationContext.java:144) ~ [spring-boot-1.5.6.RELEASE.jar: 1.5.6.RELEASE] à org.springframework.context.support.AbstractApplicationContext.refresh (AbstractApplicatio nContext.java:546) ~ [spring-context-4.3.10.RELEASE.jar: 4.3.10.RELEASE] à org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh (EmbeddedWebApplicationContext.java:122) ~ [ spring-boot-1.5.6.RELEASE.jar: 1.5.6.RELEASE] à org.springframework.boot.SpringApplication.refresh (SpringApplication.java:693) [spring-boot-1.5.6.RELEASE.jar: 1.5 .6.RELEASE] à org.springframework.boot.SpringApplication.refreshContext (SpringApplication.java:360) [spring-boot-1.5.6.RELEASE.jar: 1.5.6.RELEASE] à org.springframework.boot. SpringApplication.run (SpringApplication.java:303) [spring-boot-1.5.6.RELEASE.jar: 1.5.6.RELEASE] à l'adresse org.springframework.boot.SpringApplication.run (SpringApplication.java:1118) [print- boot-1.5.6.RELEASE.jar: 1.5.6.RELEASE] sur org.springframework.boot.SpringApplication.run (SpringApplication.java:1107) [spring-boot-1.5.6.RELEASE.jar: 1.5.6.RELEASE] à l'adresse com.demo.ConfigClientApplication.main (ConfigClientApplication.java:9) [classes /: na] Causée par: java.lang.IllegalArgumentException: Impossible de résoudre le 'message' de l'espace réservé en valeur "$ {message}" at org.springframework.util.PropertyPlaceholderHelper.parseStringValue (PropertyPlaceholderHelper.java:174) ~ [spring-core-4.3.10 .RELEASE.jar: 4.3.10.RELEASE] à org.springframework.util.PropertyPlaceholderHelper.replacePlaceholders (PropertyPlaceholderHelper.java:126) ~ [spring-core-4.3.10.RELEASE.jar: 4.3.10.RELEASE] à org.springframework.core.env.AbstractPropertyResolver.doResolvePlaceholders (AbstractPropertyResolver.java:236) ~ [spring-core-4.3.10.RELEASE.jar: 4.3.10.RELEASE] à org.springframework.core.env.AbstractPropertyResol ver.resolveRequiredPlaceholders (AbstractPropertyResolver.java:210) ~ [spring-core-4.3.10.RELEASE.jar: 4.3.10.RELEASE] à org.springframework.context.support.PropertySourcesPlaceholderConfigurer $ 2.resolveStringValue (PropertySourcesPlaceholderConfigurer.java:172) ~ [spring-context-4.3.10.RELEASE.jar: 4.3.10.RELEASE] à org.springframework.beans.factory.support.AbstractBeanFactory.resolveEmbeddedValue (AbstractBeanFactory.java:831) ~ [spring-beans-4.3 .10.RELEASE.jar: 4.3.10.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency (DefaultListableBeanFactory.java:1086) ~ [spring-beans-4.3.10.RELEASE.jar: 4.3 .10.RELEASE] à org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency (DefaultListableBeanFactory.java:1066) ~ [spring-beans-4.3.10.RELEASE.jar: 4.3.10.RELEASE] à org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor $ AutowiredFieldElement.inject (AutowiredAnnotationBeanPostProcessor.java:585) ~ [spring-beans-4.3.10.RELEASE.jar: 4.3.10.RELEASE] à org.springframework.beans .factory.annotation.InjectionMetadata.inject (InjectionMetadata.java:88) ~ [spring-beans-4.3.10.RELEASE.jar: 4.3.10.RELEASE] à org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues (AutowiredAnnotationBeanPostProcessor.java:366) ~ [printemps-haricots-4.3.10.RELEASE.jar: 4.3.10.RELEASE] ... 31 cadres communs omis

Disconnected de la cible VM, adresse: « 127,0. 01: 59908 ', transport:' socket '

+0

https://github.com/config-properties ne ressemble pas à un dépôt valide . – spencergibb

+0

désolé oublié de mentionner, c'est valide, mais ont supprimé le chemin complet. Le contenu du fichier est le même que celui des guides de ressort. – Sandhya

+0

quelque chose à partir des journaux? – spencergibb

Répondre

0

Assurez-vous que l'URI GIT est valide, elle devrait être https://github.com/userName/repositoryName puis poussez votre dossier de configurations vers repositoryName.

Exemple: https://github.com/PraveenKumarMekala/Microservices-With-Spring-Example

Ici, j'ai dossier appelé ConfigData où je mis tout mon chemin YML files.Same vous devriez également avoir un dossier avec le fichier config-client.yml (nom du fichier YML devrait être le même que votre application nom parce que vous ne l'avez pas mentionné les profils dans votre fichier YML client afin qu'il fallback à votre profil par défaut avec le nom de l'application)

vos fichiers YML devraient ressembler à ceci

config-client.yml --- message : Hello World!

Le fichier config-client.yml doit être placé dans votre repo git.

bootstrap.yml de config-client

--- spring: profiles: active: profileName application: name: config-client cloud: config: uri: http://localhost:8887 server: port: 8888

Note: Si vous mentionnez profileName alors YML nom de fichier doit être config-client-profileName.yml

application.yml de config-server

--- spring: cloud: config: server: git: uri:https://github.com/PraveenKumarMekala/Microservices-With-Spring-Example searchPaths: ConfigData # "native" is used when the native profile is active, for local tests with a classpath repo: native: searchLocations: classpath:offline-repository/ server: port: 8888

changez et essayez, espérons que c'est utile.

PS: Si vous n'avez pas compte git, créez un compte, puis dépôt

https://help.github.com/articles/create-a-repo/