---
title: "Local Development: Java & Kotlin"
description: "Run Spring Boot apps locally with secrets from Ennote instead of a .env file or credentials in application.properties, using ennote secret get with Maven or Gradle."
canonical_url: "https://docs.ennote.io/guides/local-development/java"
---
# Local Development: Java & Kotlin

> Run Spring Boot apps locally with secrets from Ennote instead of a .env file or credentials in application.properties, using ennote secret get with Maven or Gradle.

Put `ennote secret get "<secret>" --` in front of the Maven or Gradle command that starts your app. The JVM sees the values as environment variables.

The examples use a secret named `api-env`. Set your organization and workspace once with [`ennote config set`](https://docs.ennote.io/cli/commands/config), or add `--organization-id` and `--workspace-id` flags as in the [overview](https://docs.ennote.io/guides/local-development/overview#sharing-the-command-with-your-team).

## Running Spring Boot

With Maven:

```bash
ennote secret get "api-env" -- ./mvnw spring-boot:run
```

With Gradle:

```bash
ennote secret get "api-env" -- ./gradlew bootRun
```

## Mapping Keys to Spring Properties

Spring Boot maps environment variables to properties automatically (relaxed binding): uppercase the property name, replace dots with underscores and remove dashes. Name the keys of your Ennote secret accordingly:

<table>
<thead>
  <tr>
    <th>
      Key in Ennote
    </th>
    
    <th>
      Spring property
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        SPRING_DATASOURCE_URL
      </code>
    </td>
    
    <td>
      <code>
        spring.datasource.url
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        SPRING_DATASOURCE_USERNAME
      </code>
    </td>
    
    <td>
      <code>
        spring.datasource.username
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        SPRING_DATASOURCE_PASSWORD
      </code>
    </td>
    
    <td>
      <code>
        spring.datasource.password
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        STRIPE_SECRETKEY
      </code>
    </td>
    
    <td>
      <code>
        stripe.secret-key
      </code>
    </td>
  </tr>
</tbody>
</table>

No passwords are needed in `application.properties` or `application.yml`. You can also reference a variable by name with a placeholder:

```yaml [application.yml]
payment:
  api-key: ${PAYMENT_API_KEY}
```

## Plain Java and Kotlin

Read any key with `System.getenv`:

```java
String databaseUrl = System.getenv("DATABASE_URL");
```

```kotlin
val databaseUrl = System.getenv("DATABASE_URL")
```

## Running From IntelliJ IDEA

A regular Spring Boot or Application run configuration starts the JVM directly, not through Ennote, so the variables are missing. Instead, create a **Shell Script** run configuration that starts Maven through Ennote, and start the app with the usual Run button.

<steps level="3">

### Add a Shell Script run configuration

Open **Run** -> **Edit Configurations**, click **+** and choose **Shell Script**. Give it a name, for example `Spring Boot (Ennote)`.

### Enter the script

Set **Execute** to **Script text** and paste:

```bash
[ -f ~/.profile ] && source ~/.profile
[ -f ~/.bashrc ] && source ~/.bashrc
ennote secret get "api-env" --organization-id "my-org-id" --workspace-id "local-development" -- ./mvnw spring-boot:run
```

Set **Interpreter path** to `/bin/bash` and **Working directory** to your project root.

### Run it

Select the configuration and click **Run**. The app's output appears in the Run tool window.

</steps>

Why the script loads `~/.profile` and `~/.bashrc`: an IDE started from the desktop, the dock or JetBrains Toolbox does not load your shell profile, so the folder where `ennote` is installed may not be on its `PATH`. Loading the profile first gives the script the same `PATH` as your terminal. On macOS with zsh, use `/bin/zsh` as the interpreter and load `~/.zprofile` and `~/.zshrc` instead.

If your project has no Maven wrapper (`mvnw`), use the Maven bundled with IntelliJ IDEA instead of `./mvnw`. Find its folder in **Settings** -> **Build, Execution, Deployment** -> **Build Tools** -> **Maven** -> **Maven home path**, and use `<that folder>/bin/mvn`, for example:

```bash
ennote secret get "api-env" -- ~/.local/share/JetBrains/Toolbox/apps/intellij-idea-ultimate/plugins/maven-plugin/lib/maven3/bin/mvn spring-boot:run
```

The path depends on your operating system and how IntelliJ IDEA was installed. For Gradle projects, replace the Maven command with `./gradlew bootRun`.

<note>

The Ennote CLI uses the session from `ennote auth login`, stored in your OS keyring, so the run configuration needs no token. If the run fails with an authentication error, run `ennote auth login` in a terminal and try again.

</note>

<need-help>



</need-help>


## Sitemap

See the full [sitemap](https://docs.ennote.io/sitemap.md) for all pages.
