> ## Documentation Index
> Fetch the complete documentation index at: https://infisical.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Inject secrets into a Spring Boot app with Maven

> How to use Infisical to inject environment variables and secrets into a Spring Boot app with Maven.

Prerequisites:

* Set up and add your environment variables to [Infisical Cloud](https://app.infisical.com)
* [Install the CLI](https://infisical.com/docs/cli/install.md)

## Initialize Infisical

In order for Infisical to know which secrets to fetch, you'll need to first initialize Infisical at the root of your project.

```bash theme={"dark"}
# navigate to the root of your of your project 
cd /path/to/project

# then initialize Infisical
infisical init
```

## Start your application with Maven wrapper

To pass in Infisical secrets into your application, we will utilize the Infisical CLI to inject the secrets into the Maven wrapper executable, which is used to launch your application.
The Maven wrapper executable should already be present in the root directory of your project.

```bash theme={"dark"}
infisical secrets-manager run -- ./mvnw spring-boot:run --quiet
```

#### Accessing injected secrets

```java example.java theme={"dark"}
  ...
  import org.springframework.core.env.Environment;

  @SpringBootApplication
  public class DemoApplication {
    @Autowired
    private Environment env;

    @Bean
    public void someMethod() {
        System.out.println(env.getProperty("SOME_SECRET_NAME"));
      };
  }
```

## Debugging with secrets

During the process of debugging your code, it may be necessary to have certain environment variables available. To inject these variables for the purpose of debugging, please follow the instructions provided below.
Note that these instructions are currently only available for IntelliJ.

**Step 1:** On the main tool bar, choose Edit Configuration

![](https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/spring-maven-debug-1.png)

**Step 2:** Select the plus icon

![](https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/spring-maven-debug-2.png)

**Step 3:** Select Shell Script

![](https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/spring-maven-debug-3.png)

**Step 4:** Choose Script Text and then paste in the command below.

![](https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/spring-maven-debug-4.png)

```
infisical secrets-manager run -- ./mvnw spring-boot:run -Dspring-boot.run.jvmArguments="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=*:5005"
```

**Step 5:** When you need to run a block of code in debug mode, select the Infisical script

![](https://mintlify.s3.us-west-1.amazonaws.com/infisical/images/spring-maven-debug-5.png)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.