diff --git a/docs/images/spring-maven-debug-1.png b/docs/images/spring-maven-debug-1.png new file mode 100644 index 000000000..8fc5f5f7d Binary files /dev/null and b/docs/images/spring-maven-debug-1.png differ diff --git a/docs/images/spring-maven-debug-2.png b/docs/images/spring-maven-debug-2.png new file mode 100644 index 000000000..b363ebd15 Binary files /dev/null and b/docs/images/spring-maven-debug-2.png differ diff --git a/docs/images/spring-maven-debug-3.png b/docs/images/spring-maven-debug-3.png new file mode 100644 index 000000000..b21fc722f Binary files /dev/null and b/docs/images/spring-maven-debug-3.png differ diff --git a/docs/images/spring-maven-debug-4.png b/docs/images/spring-maven-debug-4.png new file mode 100644 index 000000000..1d28a08bb Binary files /dev/null and b/docs/images/spring-maven-debug-4.png differ diff --git a/docs/images/spring-maven-debug-5.png b/docs/images/spring-maven-debug-5.png new file mode 100644 index 000000000..89f0401f8 Binary files /dev/null and b/docs/images/spring-maven-debug-5.png differ diff --git a/docs/integrations/frameworks/spring-boot-maven.mdx b/docs/integrations/frameworks/spring-boot-maven.mdx new file mode 100644 index 000000000..768e819cf --- /dev/null +++ b/docs/integrations/frameworks/spring-boot-maven.mdx @@ -0,0 +1,80 @@ +--- +title: "Spring Boot with Maven" +description: "How to use Infisical to inject environment variables into Java Spring Boot" +--- + +Prerequisites: + +- Set up and add your environment variables to [Infisical Cloud](https://app.infisical.com) +- [Install the CLI](/cli/overview) + +## 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 +# 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 +infisical run -- ./mvnw spring-boot:run --quiet +``` + +#### Accessing injected secrets +```java example.java + ... + 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 + + + +**Step 2:** Click the plus icon + + + +**Step 3:** Select Shell Script + + + +**Step 4:** Choose Script Text and then paste in the command below. + + + +``` +infisical 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 + + + + + + + diff --git a/docs/mint.json b/docs/mint.json index 092535b8e..52956e7c1 100644 --- a/docs/mint.json +++ b/docs/mint.json @@ -188,6 +188,7 @@ "integrations/cicd/gitlab", "integrations/cicd/circleci", "integrations/cicd/travisci", + "integrations/frameworks/spring-boot-maven", "integrations/frameworks/react", "integrations/frameworks/vue", "integrations/frameworks/express",