11# Codegen Spring Boot Initializr
22
3+ ![ Build] ( https://github.com/bsayli/spring-boot-openapi-generics-clients/actions/workflows/build.yml/badge.svg )
34![ Java] ( https://img.shields.io/badge/Java-21-red )
45![ Spring Boot] ( https://img.shields.io/badge/Spring%20Boot-3.5-green )
56![ Maven] ( https://img.shields.io/badge/Maven-3.9-blue )
1112 <em >Social preview banner for GitHub and sharing</em >
1213</p >
1314
14- ** A customizable project generator for Spring Boot** .
15- Quickly scaffold a new Java application with predefined structure, configuration, and tests — no repetitive setup
16- required.
15+ ** A customizable project generator for Spring Boot.**
16+ Quickly scaffold a new Java application with predefined structure, configuration, and tests — no repetitive setup required.
1717
1818---
1919
@@ -37,9 +37,9 @@ Bootstrapping a new Spring Boot project often involves:
3737This project automates all of that:
3838
3939* Generates a ** ready-to-run Spring Boot project** with Maven
40- * Adds ** ` .gitignore ` , ` application.yml ` , starter class, and test class**
40+ * Adds ` .gitignore ` , ` application.yml ` , starter class, and test class
4141* Supports ** custom package and project naming**
42- * Ships with ** CLI runner** for easy one-liner project generation
42+ * Ships with ** CLI runner** for one-liner project generation
4343* Produces a ** zip archive** you can immediately extract and use
4444
4545---
@@ -66,28 +66,25 @@ mvn spring-boot:run -Dspring-boot.run.profiles=cli \
6666 -Dspring-boot.run.arguments=" --groupId=com.example --artifactId=demo-app --packageName=com.example.demo --outputDir=./target/generated-projects --overwrite=true"
6767```
6868
69- ✅ This generates a new project as a zip archive under the specified output directory (default:
70- ` ./target/generated-projects ` ):
69+ ✅ This generates a new project as a zip archive under the specified output directory (default: ` ./target/generated-projects ` ):
7170
7271```
7372[OK] Project archive generated at: /.../target/generated-projects/demo-app/demo-app.zip
7473```
7574
7675ℹ️ Tips:
7776
78- * If you don’t provide ` --outputDir ` , the project will be created under the default path ` target/generated-projects `
79- inside the current working directory.
77+ * If you don’t provide ` --outputDir ` , the project will be created under the default path ` target/generated-projects ` .
8078* If the target directory already exists:
8179
82- * By default, the generator will ** fail-fast** with a clear error.
83- * Add ` --overwrite=true ` to ** delete and regenerate** the project in the same directory.
80+ * By default, the generator will ** fail-fast** with a clear error.
81+ * Add ` --overwrite=true ` to ** delete and regenerate** the project in the same directory.
8482
8583---
8684
8785## 🧑💻 Programmatic Usage
8886
8987``` java
90-
9188import java.nio.file.Path ;
9289import java.util.List ;
9390
@@ -102,36 +99,32 @@ import io.github.bsayli.codegen.initializr.projectgeneration.service.ProjectGene
10299// Assume ProjectGenerationService is injected or obtained from Spring context
103100ProjectGenerationService service = /* @Autowired or ApplicationContext.getBean(...) */ ;
104101
105- var depWeb =
106- new Dependency .DependencyBuilder ()
107- .groupId(" org.springframework.boot" )
108- .artifactId(" spring-boot-starter-web" )
109- .build();
110-
111- var depTest =
112- new Dependency .DependencyBuilder ()
113- .groupId(" org.springframework.boot" )
114- .artifactId(" spring-boot-starter-test" )
115- .scope(" test" )
116- .build();
117-
118- var metadata = new SpringBootJavaProjectMetadataBuilder ()
119- .springBootVersion(" 3.5.5" )
120- .javaVersion(" 21" )
121- .groupId(" com.example" )
122- .artifactId(" demo-app" )
123- .name(" demo-app" )
124- .description(" Generated by codegen-initializr-core" )
125- .packageName(" com.example.demo" )
126- .dependencies(List . of(depWeb, depTest))
127- .build();
128-
129- var type = new ProjectType (Framework . SPRING_BOOT , BuildTool . MAVEN , Language . JAVA );
130-
131- Path zip = service. generateProject(type, metadata);
132- System . out.
133-
134- println(" Archive generated at: " + zip. toAbsolutePath());
102+ var depWeb = new Dependency .DependencyBuilder ()
103+ .groupId(" org.springframework.boot" )
104+ .artifactId(" spring-boot-starter-web" )
105+ .build();
106+
107+ var depTest = new Dependency .DependencyBuilder ()
108+ .groupId(" org.springframework.boot" )
109+ .artifactId(" spring-boot-starter-test" )
110+ .scope(" test" )
111+ .build();
112+
113+ var metadata = new SpringBootJavaProjectMetadataBuilder ()
114+ .springBootVersion(" 3.5.5" )
115+ .javaVersion(" 21" )
116+ .groupId(" com.example" )
117+ .artifactId(" demo-app" )
118+ .name(" demo-app" )
119+ .description(" Generated by codegen-initializr-core" )
120+ .packageName(" com.example.demo" )
121+ .dependencies(List . of(depWeb, depTest))
122+ .build();
123+
124+ var type = new ProjectType (Framework . SPRING_BOOT , BuildTool . MAVEN , Language . JAVA );
125+
126+ Path zip = service. generateProject(type, metadata);
127+ System . out. println(" Archive generated at: " + zip. toAbsolutePath());
135128```
136129
137130---
@@ -184,16 +177,14 @@ Run the test suite:
184177mvn test
185178```
186179
187- The generator components (` pom.xml ` , ` .gitignore ` , ` application.yml ` , layout, archiver) are fully covered with unit &
188- integration tests.
180+ The generator components (` pom.xml ` , ` .gitignore ` , ` application.yml ` , layout, archiver) are fully covered with unit & integration tests.
189181
190182---
191183
192184## 📖 Related Work
193185
194186This tool is inspired by the need to automate repetitive ** Spring Boot project initialization** tasks.
195- It works well alongside other repositories
196- like [ spring-boot-openapi-generics-clients] ( https://github.com/bsayli/spring-boot-openapi-generics-clients ) .
187+ It works well alongside other repositories like [ spring-boot-openapi-generics-clients] ( https://github.com/bsayli/spring-boot-openapi-generics-clients ) .
197188
198189---
199190
0 commit comments