Java

Prerequisites

Import Dapr’s Java SDK

Next, import the Java SDK packages to get started. Select your preferred build tool to learn how to import.

For a Maven project, add the following to your pom.xml file:

  1. <project>
  2. ...
  3. <dependencies>
  4. ...
  5. <!-- Dapr's core SDK with all features, except Actors. -->
  6. <dependency>
  7. <groupId>io.dapr</groupId>
  8. <artifactId>dapr-sdk</artifactId>
  9. <version>1.9.0</version>
  10. </dependency>
  11. <!-- Dapr's SDK for Actors (optional). -->
  12. <dependency>
  13. <groupId>io.dapr</groupId>
  14. <artifactId>dapr-sdk-actors</artifactId>
  15. <version>1.9.0</version>
  16. </dependency>
  17. <!-- Dapr's SDK integration with SpringBoot (optional). -->
  18. <dependency>
  19. <groupId>io.dapr</groupId>
  20. <artifactId>dapr-sdk-springboot</artifactId>
  21. <version>1.9.0</version>
  22. </dependency>
  23. ...
  24. </dependencies>
  25. ...
  26. </project>

For a Gradle project, add the following to your build.gradle file:

  1. dependencies {
  2. ...
  3. // Dapr's core SDK with all features, except Actors.
  4. compile('io.dapr:dapr-sdk:1.9.0')
  5. // Dapr's SDK for Actors (optional).
  6. compile('io.dapr:dapr-sdk-actors:1.9.0')
  7. // Dapr's SDK integration with SpringBoot (optional).
  8. compile('io.dapr:dapr-sdk-springboot:1.9.0')
  9. }

If you are also using Spring Boot, you may run into a common issue where the OkHttp version that the Dapr SDK uses conflicts with the one specified in the Spring Boot Bill of Materials.

You can fix this by specifying a compatible OkHttp version in your project to match the version that the Dapr SDK uses:

  1. <dependency>
  2. <groupId>com.squareup.okhttp3</groupId>
  3. <artifactId>okhttp</artifactId>
  4. <version>4.9.0</version>
  5. </dependency>

Try it out

Put the Dapr Java SDK to the test. Walk through the Java quickstarts and tutorials to see Dapr in action:

SDK samplesDescription
QuickstartsExperience Dapr’s API building blocks in just a few minutes using the Java SDK.
SDK samplesClone the SDK repo to try out some examples and get started.

More information

Learn more about the Dapr Java SDK packages available to add to your Java applications.


Dapr Java SDK

Java SDK packages for developing Dapr applications

Workflow

How to get up and running with the Dapr Workflow extension