java-sdk/daprdocs/content/en/java-sdk-docs/_index.md

3.4 KiB

type title linkTitle weight description cascade
docs Dapr Java SDK Java 1000 Java SDK packages for developing Dapr applications
github_repo github_subdir path_base_for_github_subdir github_branch
https://github.com/dapr/java-sdk daprdocs/content/en/java-sdk-docs content/en/developing-applications/sdks/java/ master

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.

{{< tabs Maven Gradle >}}

{{% codetab %}}

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

<project>
  ...
  <dependencies>
    ...
    <!-- Dapr's core SDK with all features, except Actors. -->
    <dependency>
      <groupId>io.dapr</groupId>
      <artifactId>dapr-sdk</artifactId>
      <version>1.9.0</version>
    </dependency>
    <!-- Dapr's SDK for Actors (optional). -->
    <dependency>
      <groupId>io.dapr</groupId>
      <artifactId>dapr-sdk-actors</artifactId>
      <version>1.9.0</version>
    </dependency>
    <!-- Dapr's SDK integration with SpringBoot (optional). -->
    <dependency>
      <groupId>io.dapr</groupId>
      <artifactId>dapr-sdk-springboot</artifactId>
      <version>1.9.0</version>
    </dependency>
    ...
  </dependencies>
  ...
</project>

{{% /codetab %}}

{{% codetab %}}

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

dependencies {
...
    // Dapr's core SDK with all features, except Actors.
    compile('io.dapr:dapr-sdk:1.9.0')
    // Dapr's SDK for Actors (optional).
    compile('io.dapr:dapr-sdk-actors:1.9.0')
    // Dapr's SDK integration with SpringBoot (optional).
    compile('io.dapr:dapr-sdk-springboot:1.9.0')
}

{{% /codetab %}}

{{< /tabs >}}

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:

<dependency>
  <groupId>com.squareup.okhttp3</groupId>
  <artifactId>okhttp</artifactId>
  <version>4.9.0</version>
</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 samples Description
[Quickstarts]({{< ref quickstarts >}}) Experience Dapr's API building blocks in just a few minutes using the Java SDK.
SDK samples Clone 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.