In this tutorial, you will learn how to create a Spring Boot application using Spring Initializr and add flake.nix
for development.
Initialize a Spring Boot project
Section titled “Initialize a Spring Boot project”Go to Spring Initializr and configure your project. This example chooses Gradle (Kotlin) and the Java language. You can also add dependencies as needed. Click Generate to download the project as a ZIP file.
Extract the ZIP file to your desired location:
Terminal window unzip demo.zipcd demo
Add flake.nix to the project
Section titled “Add flake.nix to the project”Initialize the Java template from the root directory of the Spring Boot project:
Terminal window nix flake init -t github:akirak/flake-templates#javaEnsure the JDK version in your
flake.nix
matches your project requirement:jdk = pkgs.openjdk21_headless;Add
.envrc
:Terminal window use flakeAllow direnv:
Terminal window direnv allow