跳到正文
Skillpedia
API 与服务器(后端)40k · #7144

create-spring-boot-java-project

它能做什么

这个工具会为使用 Spring Boot 的 Java 项目创建基础结构。它会下载一个模板,并添加必要的配置和依赖,让你可以开始开发。

适用场景

  • ✓需要用 Java 和 Spring Boot 开始一个新的 Web 项目时。
  • ✓想快速搭建带有数据库(PostgreSQL、MongoDB)和缓存(Redis)的项目时。
  • ✓希望一开始就配置好自动生成文档(Swagger)的起点时。

技能链接

https://github.com/github/awesome-copilot/blob/main/skills/create-spring-boot-java-project/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/github/awesome-copilot/blob/main/skills/create-spring-boot-java-project/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“创建一个名为“my-web-app”的 Spring Boot 项目,依赖包括 web、JPA 和 PostgreSQL。”

每周 5 个新技能,1 分钟读完。

工作原理

这个工具会下载 Spring Boot 项目模板,添加数据库、缓存和文档相关的配置,并准备一个文件,用 Docker 运行 PostgreSQL 和 Redis 等服务。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Create Spring Boot Java project prompt

Check Java version

  • Run following command in terminal and check the version of Java
java -version

Download Spring Boot project template

  • Run following command in terminal to download a 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

  • Run following command in terminal to unzip the downloaded file
unzip starter.zip -d ./${input:projectName:demo-java}

Remove the downloaded zip file

  • Run following command in terminal to delete the downloaded zip file
rm -f starter.zip

Change directory to the project root

  • Run following command in terminal to change directory to the project root
cd ${input:projectName:demo-java}

Add additional dependencies

  • Insert springdoc-openapi-starter-webmvc-ui and archunit-junit5 dependency into pom.xml file
<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

  • Insert SpringDoc configurations into application.properties file
# SpringDoc configurations
springdoc.swagger-ui.doc-expansion=none
springdoc.swagger-ui.operations-sorter=alpha
springdoc.swagger-ui.tags-sorter=alpha
  • Insert Redis configurations into application.properties file
# Redis configurations
spring.data.redis.host=localhost
spring.data.redis.port=6379
spring.data.redis.password=rootroot
  • Insert JPA configurations into application.properties file
# 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
  • Insert MongoDB configurations into application.properties file
# 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

  • Create docker-compose.yaml at project root and add following services: redis:6, postgresql:17 and mongo:8.

    • redis service should have
      • password rootroot
      • mapping port 6379 to 6379
      • mounting volume ./redis_data to /data
    • postgresql service should have
      • password rootroot
      • mapping port 5432 to 5432
      • mounting volume ./postgres_data to /var/lib/postgresql/data
    • mongo service should have
      • initdb root username root
      • initdb root password rootroot
      • mapping port 27017 to 27017
      • mounting volume ./mongo_data to /data/db

Add .gitignore file

  • Insert redis_data, postgres_data and mongo_data directories in .gitignore file

Run Maven test command

  • Run maven clean test command to check if the project is working
./mvnw clean test

Run Maven run command (Optional)

  • (Optional) docker-compose up -d to start the services, ./mvnw spring-boot:run to run the Spring Boot project, docker-compose rm -sf to stop the services.

Let's do this step by step

常见问题

我需要先安装哪些软件?

你需要在电脑上安装 Java 21、Docker 和 Docker Compose。

如何修改项目名称或 Spring Boot 版本?

你可以修改 `artifactId` 和 `packageName` 来更改项目名称,也可以修改下载命令中的 `bootVersion` 来更改 Spring Boot 版本。

添加了哪些依赖?

这些是项目可能需要的额外功能,例如用于创建 Web 应用的 `web`、用于使用数据库的 `data-jpa` 和 `postgresql`、用于缓存的 `data-redis`、用于自动生成文档的 `springdoc-openapi`,以及用于测试的 `testcontainers`。

详情

作者的原始描述

Create Spring Boot Java Project Skeleton

repo: github/awesome-copilot

热度

GitHub 星标
40k
排名
#7144
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能