2017-08-18 9 views
0

config-clientがエラーを下回っている間に...スプリングガイドから直接的に簡単なことは動作しません。設定 - クライアントサービスからSpring Cloud Config Service - クライアントが動作しない

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 

ログ

エラーのApplicationContextを開始します。自動構成レポートを表示するには、「デバッグ」を有効にしてアプリケーションを再実行します。 2017年8月18日23:13:45.080 ERROR 13812 --- [メイン] osboot.SpringApplication:エラーが「scopedTarget.restController名前でBeanを作成:アプリケーションの起動が

org.springframework.beans.factory.BeanCreationExceptionを失敗しました':autowired依存関係の注入が失敗しました。入れ子にされた例外はjava.lang.IllegalArgumentExceptionです。値 "$ {message}"のプレースホルダ 'message'を解決できませんでした。 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:372)〜[spring- 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] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)〜[spring-beans-4.3.10.RELEASE] .jar:4.3.10.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory $ 2.getObject(AbstractBeanFactory.java:345)〜[spring-beans-4.3.10.RELEASE.jar:4.3.10。 (Springer-Cloud-Context-1.2.3.RELEASE.jar:1.2.3.RELEASE] at) org.springframework.cloud.context.scope.GenericScope.get(GenericScope.java:176)〜[spring-cloud-context-1.2.3.RELEASE.jar:1.2.3.RELEASE] at org.springframework.beans。 factory.Support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:340)〜[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean( AbstractBeanFactory.java:197)〜[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE] at org.spring framework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1078)〜[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE] at org.springframework.cloud.context.scope.refresh。 RefreshScope.start(RefreshScope.java:121)〜[spring-cloud-context-1.2.3.RELEASE.jar:1.2.3.RELEASE] at sun.reflect.NativeMethodAccessorImpl.invoke0(ネイティブメソッド)〜[na:1.8 .0_144] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)〜[na:1.8.0_144] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)〜[na:1.8.0_144] ] at java.lang.reflect.Mava.Avoke(Method.java:498)〜[na:1.8.0_144] at org.springframework.context.event.ApplicationListenerMethodAdapter.doInvoke(ApplicationListenerMethodAdapter.java:256)〜[spring -context-4.3.10.RELEASE .jar:4.3.10.RELEASE] at 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] at org.springframework.context.event.SimpleApplicationEventMulticaster .invokeListener(SimpleApplicationEventMulticaster.java:167)〜[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE] at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster。java:139)〜[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:393)〜[spring-context- 4.3.10.RELEASE.jar:4.3.10.RELEASE] at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:347)〜[spring-context-4.3.10.RELEASE.jar:4.3。 10.RELEASE] at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:883)〜[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE] at org.springframework。 (SpringWebApplicationContext.java:144)〜[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh AbstractApplicatio nContext.java:546)〜[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)〜[ spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:693)[spring-boot-1.5.6.RELEASE.jar:1.5 (SpringApplication.java:360)[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at org.springframework.boot。 SpringApplication.run(SpringApplication.java:303)[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1118)[spring- boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at org.springframework.boot.SpringApplication.run (SpringApplication.java:1107)[spring-boot-1.5.6.RELEASE.jar:1.5.6.RELEASE] at com.demo.ConfigClientApplication.main(ConfigClientApplication.java:9)[classes /:na] 原因by:java.lang.IllegalArgumentException:値 "$ {message}"のプレースホルダ 'message'を解決できませんでした org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:174)〜[spring-core-4.3.10 .RELEASE.jar:4.3.10.RELEASE] at 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] at org.springframework.core.env.AbstractPropertyResol (AbstractPropertyResolver.java:210)〜[spring-core-4.3.10.RELEASE.jar:4.3.10.RELEASE] at org.springframework.context.support.PropertySourcesPlaceholderConfigurer $ 2.resolveStringValue(PropertySourcesPlaceholderConfigurer.java:172) )〜[spring-context-4.3.10.RELEASE.jar:4.3.10.RELEASE] at 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] at 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] at org.springframework.beans .factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)〜[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE] at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues (AutowiredAnnotationBeanPostProcessor.java:366)〜[春豆-4.3.10.RELEASE.jar:4.3.10.RELEASE]:「127.0 ... 31個の共通フレームがターゲットVM、アドレスから切断

を省略しました。 0。1:59908 '、transport:' socket '

+0

https://github.com/config-propertiesは有効なリポジトリのようには見えません。 。 – spencergibb

+0

申し訳ありませんが、妥当だと言いましたが、完全なパスが削除されました。ファイルの内容はスプリングガイドと同じです。 – Sandhya

+0

ログの内容は何ですか? – spencergibb

答えて

0

GIT URIが有効であることを確認してください。https://github.com/userName/repositoryName を入力し、次にコンフィグレーションフォルダをrepositoryNameにプッシュします。

例:ここではhttps://github.com/PraveenKumarMekala/Microservices-With-Spring-Example

が、私はまた、あなたのアプリケーションと同じでなければなりません設定-client.ymlファイル(YMLファイル名で一つのフォルダを持っている必要があり、すべての私のYMLのfiles.Sameの道を置いCONFIGDATAというフォルダを持っていますあなたYMLファイルが

設定-client.yml以下のようになります

)それはあなたのアプリケーション名を使用して、デフォルトのプロファイルにフォールバックされますので、あなたのクライアントYMLファイル内の任意のプロファイルを言及していないので名前210 --- message : Hello World!

config-client.ymlファイルをgit repoに配置する必要があります。設定 - クライアントの

bootstrap.yml

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

注:あなたはプロファイル名に言及した場合、YMLファイル名は設定 - クライアントprofileName.yml

する必要がありますconfig-serverのapplication.yml

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

これを変更して試してみると便利です。

PS:あなたはgitのアカウントをお持ちでない場合は、アカウントを作成し、その後、リポジトリ

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

関連する問題