启动一个非常基本的Spring Boot应用程序使用spring-cloud-starter-aws-secrets-manager-config
来检索AWS sectrets
工作正常。但是,当我将spring-boot-starter-web dependency
Web 服务支持添加到项目中时,the spring-cloud-starter-aws-secrets-manager-config
errors
应用程序无法启动。
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-aws-secrets-manager-config</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>
<!-- if I remove spring-boot-starter-web it all starts properly -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
爪哇
package com.secrets.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class App
{
public static void main( String[] args )
{
SpringApplication.run(App.class, args);
}
}
引导程序.yml
spring:
application:
name: app_name
aws:
secretsmanager:
prefix: /secret
defaultContext: application
profileSeparator: _
failFast: true
name: app_name
enabled: true
应用程序应该可以正常启动,但是应用程序会出现以下错误:
启动 ApplicationContext 时出错。要显示自动配置报告,请在启用“调试”的情况下重新运行您的应用程序。2019-07-03 11:57:16.563 错误 73839 --- [main] osboot.SpringApplication:应用程序启动失败
org.springframework.beans.factory.UnsatisfiedDependencyException:创建名称为“propertySourceBootstrapConfiguration”的bean时出错:通过字段“propertySourceLocators”表示的依赖关系不满足;嵌套异常是 org.springframework.beans.factory.UnsatisfiedDependencyException:在 org.springframework.cloud.aws.autoconfigure.secretsmanager.AwsSecretsManagerBootstrapConfiguration 中定义名称为“awsSecretsManagerPropertySourceLocator”的 bean 创建错误:通过方法“awsSecretsManagerPropertySourceLocator”参数 1 表示的依赖关系不满足;嵌套异常是 org.springframework.beans.factory.BeanCreationException:创建名称为“aws.secretsmanager-org.springframework.cloud.aws.secretsmanager.AwsSecretsManagerProperties”的 bean 时出错:无法将属性绑定到 AwsSecretsManagerProperties(prefix=aws.secretsmanager、ignoreInvalidFields=false、ignoreUnknownFields=true、ignoreNestedProperties=false);嵌套异常是 java.lang.NullPointerException 在 org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:588) ~[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) ~[spring-beans-4.3.10.RELEASE.jar:4.3.10.RELEASE] at org.springframework.beans。