簡體   English   中英

Spring Boot - 如何將 application.yml 屬性定義為 application.properties

[英]Spring Boot - How to define application.yml properties as application.properties

我目前正在嘗試使用我的 Spring Boot webapp 設置一個 s3 存儲桶以添加/刪除圖像。

我遵循的指南使用以下 application.yml 屬性:

amazonProperties:
  endpointUrl: https://s3.us-east-2.amazonaws.com
  accessKey: XXXXXXXXXXXXXXXXX
  secretKey: XXXXXXXXXXXXXXXXXXXXXXXXXX
  bucketName: your-bucket-name

如何在我的 application.properties 文件中定義這些屬性?

非常感謝所有幫助,謝謝!

嘗試在application.properties中將它們拆分為不同的行:

amazonProperties.endpointUrl= https://s3.us-east-2.amazonaws.com
amazonProperties.accessKey= XXXXXXXXXXXXXXXXX
amazonProperties.secretKey= XXXXXXXXXXXXXXXXXXXXXXXXXX
amazonProperties.bucketName= your-bucket-name

如果您使用的是 spring Spring Cloud AWS maven 依賴<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-aws</artifactId> </dependency>

application.properties文件中使用以下屬性。

cloud.aws.region.static=your region cloud.aws.credentials.accessKey=your access key cloud.aws.credentials.secretKey=your secret key app.awsServices.bucketName=bucketName

參考: https : //cloud.spring.io/spring-cloud-static/spring-cloud-aws/1.2.3.RELEASE/multi/multi__basic_setup.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM