Home / Market / create spring boot java project

create spring boot java project

Create Spring Boot Java Project Skeleton

skill★ 417949610 dlskills.shMITInstall in CosmosUpstream Source

Documentation & Preview

--- name: create-spring-boot-java-project description: 'Create Spring Boot Java Project Skeleton'

---

Create Spring Boot Java project prompt

Check Java version

java -version

Download Spring Boot project template

curl https://start.spring.io/starter.zip \
  -d artifactId=${input:projectName:demo-java} \
  -d bootVersion=3.4.5 \
  -d dependencies=lombok,configuration-processor,web,data-jpa,postgresql,data-redis,data-mongodb,validation,cache,testcontainers \
  -d javaVersion=21 \
  -d packageName=com.example \
  -d packaging=jar \
  -d type=maven-project \
  -o starter.zip

Unzip the downloaded file

unzip starter.zip -d ./${input:projectName:demo-java}

Remove the downloaded zip file

rm -f starter.zip

Change directory to the project root

cd ${input:projectName:demo-java}

Add additional dependencies

<dependency>
  <groupId>org.springdoc</groupId>
  <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
  <version>2.8.6</version>
</dependency>
<dependency>
  <groupId>com.tngtech.archunit</groupId>
  <artifactId>archunit-junit5</artifactId>
  <version>1.2.1</version>
  <scope>test</scope>
</dependency>

Add SpringDoc, Redis, JPA and MongoDB configurations

# SpringDoc configurations
springdoc.swagger-ui.doc-expansion=none
springdoc.swagger-ui.operations-sorter=alpha
springdoc.swagger-ui.tags-sorter=alpha
# Redis configurations
spring.data.redis.host=localhost
spring.data.redis.port=6379
spring.data.redis.password=rootroot
# JPA configurations
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
spring.datasource.username=postgres
spring.datasource.password=rootroot
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.format_sql=true
# MongoDB configurations
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.authentication-database=admin
spring.data.mongodb.username=root
spring.data.mongodb.password=rootroot
spring.data.mongodb.database=test

Add docker-compose.yaml with Redis, PostgreSQL and MongoDB services

Add .gitignore file

Run Maven test command

./mvnw clean test

Run Maven run command (Optional)

Let's do this step by step