View on GitHub

dapr-spring

Dapr SpringBoot Starter - Let the Dapr works just like what Spring Cloud does.

Getting Started Guide

<- Back to Index

This section outlines the necessary steps to integrate your application with the dapr-secretstore-spring-boot-starter project.

Adding Dependencies

This artifact is released on GitHub Packages, JitPack, and Maven Central for daily builds, SNAPSHOT versions, and stable releases. Please select the appropriate version for use.

Refer to How to Download Artifacts to complete the Repository configuration and add the following dependencies (if dapr-spring-boot-starter has already been added, this can be ignored):

GitHub Packages, Maven Central

<dependency>
    <groupId>icu.fangkehou</groupId>
    <artifactId>dapr-client-spring-boot-starter</artifactId>
    <version>0.4.0-SNAPSHOT</version>
</dependency>
dependencies {
    implementation 'icu.fangkehou:dapr-client-spring-boot-starter:0.4.0-SNAPSHOT'
}

Please note: The above version number may be outdated, ensure you are using the latest version. Components may require you to introduce additional dependencies.

For details, see Version Overview

JitPack

<dependency>
    <groupId>icu.fangkehou.dapr-spring</groupId>
    <artifactId>dapr-client-spring-boot-starter</artifactId>
    <version>0.4.0-SNAPSHOT</version>
</dependency>
dependencies {
    implementation 'icu.fangkehou.dapr-spring:dapr-client-spring-boot-starter:0.4.0-SNAPSHOT'
}

Please note: The above version number may be outdated, ensure you are using the latest SNAPSHOT version. Components may require you to introduce additional dependencies.

For details, see Version Overview

Basic Usage

After correctly adding the dependencies, add the following fields to your application’s configuration:

spring:
  config:
    import: dapr:secret:mysecret/secret

or

spring.config.import = dapr:secret:mysecret/secret

Where dapr:secret: is the fixed field for the dapr secret store configuration, and the subsequent mysecret/secret is the user-configured secret location, formatted as [Secret Store Name]/[Secret Name]. You can also provide only the Secret Store Name, in which case the Dapr Client will retrieve all Secrets under that Secret Store using Bulk, with the secret location formatted as [Secret Store Name].

Please note: To avoid parsing failures, do not add any extra characters (such as “/”, “:”) at the beginning, end, or middle of the secret location.

The document translates the Dapr Secret Store by converting the Secret Store configuration into a string in the Spring Boot Properties format for parsing. Therefore, when configuring the Secret Store, please store the secret key in a format similar to spring.mysql.username.

Please note: If the Secret is in a nested format, such as using json in localfile mode and nesting more than two layers, you need to set the nestedSeparator to .. The standard retrieval mode requires the ‘multiValued’ setting to be set to true. If your Secret Store implementation does not support ‘multiValue’, please use the Bulk mode to retrieve Secrets.

It’s important to note that since the configuration import process occurs during the Bootstrap phase, when the Spring IOC has not yet begun the batch Bean creation process, it is not possible to inject DaprClient by specifying @Bean in the Application Configuration.

Additional Information

Please refer to other entries on the Homepage for more ways to use it, and consult the Configuration entry to configure the various parameters of DaprClient.


<- Back to Index