简体   繁体   English

无法使用 Spring 引导连接到 AWS SSM 参数

[英]Unable to connect to AWS SSM parameter using Spring boot

I want my spring boot application to connect AWS SSM parameter (Spring Boot Properties to an AWS System Manager Parameter Store)我希望我的 spring 启动应用程序连接 AWS SSM 参数(Spring Boot Properties to an AWS System Manager Parameter Store)

While am starting my spring boot app, it throws the following error在启动我的 spring 启动应用程序时,它会引发以下错误

org.springframework.boot.context.config.ConfigDataResourceNotFoundException: Config data resource '[AwsParamStoreConfigDataResource@34e20e6b context = '/config/application/', optional = false]' via location 'aws-parameterstore:' cannot be found
    at org.springframework.boot.context.config.ConfigDataResourceNotFoundException.withLocation(ConfigDataResourceNotFoundException.java:97)
    at org.springframework.boot.context.config.ConfigDataImporter.handle(ConfigDataImporter.java:145)
    at org.springframework.boot.context.config.ConfigDataImporter.load(ConfigDataImporter.java:136)
    at org.springframework.boot.context.config.ConfigDataImporter.resolveAndLoad(ConfigDataImporter.java:86)
    at org.springframework.boot.context.config.ConfigDataEnvironmentContributors.withProcessedImports(ConfigDataEnvironmentContributors.java:121)
    at org.springframework.boot.context.config.ConfigDataEnvironment.processWithProfiles(ConfigDataEnvironment.java:311)
    at org.springframework.boot.context.config.ConfigDataEnvironment.processAndApply(ConfigDataEnvironment.java:232)
    at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:102)
    at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:94)
    at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:102)
    at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:87)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
    at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
    at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
    at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
    at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111)
    at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62)
    at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:374)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:332)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1332)
    at com.rnd.aws.AwsApplication.main(AwsApplication.java:10)
Caused by: com.amazonaws.SdkClientException: Unable to find a region via the region provider chain. Must provide an explicit region in the builder or setup environment to supply a region.
    at com.amazonaws.client.builder.AwsClientBuilder.setRegion(AwsClientBuilder.java:462)
    at com.amazonaws.client.builder.AwsClientBuilder.configureMutableProperties(AwsClientBuilder.java:424)
    at com.amazonaws.client.builder.AwsSyncClientBuilder.build(AwsSyncClientBuilder.java:46)
    at io.awspring.cloud.autoconfigure.paramstore.AwsParamStoreBootstrapConfiguration.createSimpleSystemManagementClient(AwsParamStoreBootstrapConfiguration.java:82)
    at io.awspring.cloud.autoconfigure.paramstore.AwsParamStoreConfigDataLocationResolver.createSimpleSystemManagementClient(AwsParamStoreConfigDataLocationResolver.java:124)
    at org.springframework.boot.DefaultBootstrapContext.getInstance(DefaultBootstrapContext.java:119)
    at org.springframework.boot.DefaultBootstrapContext.getOrElseThrow(DefaultBootstrapContext.java:111)
    at org.springframework.boot.DefaultBootstrapContext.get(DefaultBootstrapContext.java:88)
    at io.awspring.cloud.autoconfigure.paramstore.AwsParamStoreConfigDataLoader.load(AwsParamStoreConfigDataLoader.java:38)
    at io.awspring.cloud.autoconfigure.paramstore.AwsParamStoreConfigDataLoader.load(AwsParamStoreConfigDataLoader.java:33)
    at org.springframework.boot.context.config.ConfigDataLoaders.load(ConfigDataLoaders.java:107)
    at org.springframework.boot.context.config.ConfigDataImporter.load(ConfigDataImporter.java:128)
    ... 23 common frames omitted
11:52:05.333 [main] ERROR org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter - 

APPLICATION FAILED TO START应用程序无法启动


Description:描述:

Config data resource '[AwsParamStoreConfigDataResource@34e20e6b context = '/config/application/', optional = false]' via location 'aws-parameterstore:' does not exist通过位置 'aws-parameterstore:' 配置数据资源 '[AwsParamStoreConfigDataResource@34e20e6b context = '/config/application/', optional = false]' 不存在

Action:行动:

Check that the value 'aws-parameterstore:' at class path resource [application.properties] - 5:22 is correct, or prefix it with 'optional:'检查 class 路径资源 [application.properties] - 5:22 处的值“aws-parameterstore:”是否正确,或在其前面加上“可选:”

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

在此处输入图像描述

Please help me请帮我

Add this properties to your bootstrap.yml将此属性添加到您的 bootstrap.yml

spring:
  application:
    name: fahim
  profiles:
    active: local

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM