Spring Boot Java 项目搭建
create-spring-boot-java-project
从 start.spring.io 创建一个新的 Spring Boot Java 项目(Maven 或 Gradle),并为配置、PostgreSQL、日志、安全、测试和 Docker 提供合理的默认设置。当用户要求搭建、引导或生成 Spring Boot 应用程序时使用。会检测现有项目版本,且绝不隐式升级。
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 4.1w
- Forks
- 5.4k
01 前言 Front Matter
- name
- create-spring-boot-java-project
- description
- Create a new Spring Boot Java project (Maven or Gradle) from start.spring.io with sensible defaults for configuration, PostgreSQL, logging, security, testing and Docker. Use when asked to scaffold, bootstrap or generate a Spring Boot application. Detects existing project versions and never upgrades implicitly.
02 资源文件 12
- 资产文件assets/Dockerfile2.1 KB
- 资产文件assets/Dockerfile-gradle2.5 KB
- 资产文件assets/Dockerfile-native1.2 KB
- 资产文件assets/Dockerfile-native-gradle1.3 KB
- 参考文档references/configuration.md2.2 KB
- 参考文档references/database.md3.4 KB
- 参考文档references/docker.md4.4 KB
- 参考文档references/logging.md1.6 KB
- 参考文档references/PROVENANCE.md1.7 KB
- 参考文档references/security.md2.4 KB
- 参考文档references/spring-boot-4.md2.2 KB
- 参考文档references/versions.md2.6 KB
03 SKILL.md 正文
Create a Spring Boot Java project
Scaffold a Spring Boot application with start.spring.io, then apply a small set of opinionated defaults. Out of scope for now: front-ends (Vue/React/Angular), cloud deployment (Azure), Git setup, CRaC and AOT images.
Step 0: Detect before you create
- If the working directory already contains a
pom.xmlorbuild.gradle(.kts), this is an existing project: do not regenerate it. Read its Spring Boot, Java and test-framework versions and follow them. Never upgrade versions implicitly; propose an upgrade and wait for the user's decision. - Check the tools:
java -version(JDK matching the chosen Java version),docker --version(needed for Testcontainers and Compose). On the default path (current Boot via start.spring.io) Maven/Gradle need not be installed: the generated wrapper is used. The Boot 3.5 fallback needs Maven or Gradle installed once to create the wrapper (see versions.md). - Ask only for what is missing: project name, group id, package, build tool (default Maven), dependencies (default: web, actuator, validation, devtools; add
data-jpa,postgresql,security,docker-compose,testcontainerswhen a database or auth is needed).
Step 1: Resolve versions
Follow references/versions.md: query https://start.spring.io/metadata/client at run time for the latest stable Spring Boot release, fall back to the documented pinned values if offline. Do not hardcode latest anywhere.
Step 2: Generate the project
Use the start.spring.io HTTP API with explicit, pinned parameters (no piped installers). Replace the values in capitals.
Maven:
curl -fsS https://start.spring.io/starter.zip \
-d type=maven-project -d language=java -d packaging=jar \
-d bootVersion=BOOT_VERSION -d javaVersion=JAVA_VERSION \
-d groupId=com.example -d artifactId=demo -d name=demo \
-d packageName=com.example.demo -d baseDir=demo \
-d dependencies=web,actuator,validation,devtools \
-o demo.zip && unzip -q demo.zip && rm demo.zip
Gradle: same command with -d type=gradle-project (Groovy DSL) or -d type=gradle-project-kotlin (Kotlin DSL; the language stays java).
Inspect the result (ls demo, read the build file) and make sure the wrapper (mvnw or gradlew) is executable. Add -d dependencies=...,data-jpa,postgresql,docker-compose,testcontainers for a database project.
Step 3: Apply the defaults
| Area | What to do | Reference |
|---|---|---|
| Boot 3 vs 4 differences | Starter names, Jackson 3, test modules | references/spring-boot-4.md |
| Configuration | application.properties or .yml (match the project), profiles, @ConfigurationProperties, secrets via environment |
references/configuration.md |
| Database | PostgreSQL, Hibernate settings, Compose for dev, Testcontainers for tests | references/database.md |
| Logging | SLF4J, parameterized messages, levels, structured logging | references/logging.md |
| Security | Spring Security basics, secure defaults, Problem Details | references/security.md |
| Docker | JVM image and GraalVM native image Dockerfiles | references/docker.md |
| Testing | See the spring-boot-testing skill (slices, Testcontainers, Failsafe) |
skills/spring-boot-testing |
| Best practices | See the java-springboot skill and instructions/springboot.instructions.md |
skills/java-springboot |
Keep dotfiles minimal: a .gitignore covering target/, build/, .gradle/, IDE folders and .env; never commit .env (commit a .env.sample).
Step 4: Verify
- Build and test:
./mvnw verify(Maven) or./gradlew build(Gradle). - Run:
./mvnw spring-boot:runor./gradlew bootRun, thencurl -fsS localhost:8080/actuator/healthmust return{"status":"UP"}. - Report the chosen versions and anything that was skipped or deferred.
Provenance
Adapted from the Apache-2.0 skill jdubois/dr-jskill; see references/PROVENANCE.md.
04 同仓库更多 Skills
sap-cloud-integration
SAP Cloud Integration (CPI, part of SAP Integration Suite) runtime-specific guidance for building and troubleshooting iFlows. Use when writing or reviewing CPI Groovy scripts, choosing headers vs. exchange properties, designing exception subprocesses, JMS retry, idempotency or data store patterns, or diagnosing adapter errors (SFTP, HTTP/OAuth, SOAP, IDoc, OData, AS2, Cloud Connector) from Message Processing Log (MPL) text. Not for SAP PI/PO, ABAP development, or generic Java/Groovy outside CPI.
on-device-delegate
Saves cloud-model context by briefing one bounded, read-heavy sub-task (more than about 25 KB of prose, or many files that no single command can answer) to the local-coding plugin's on-device worker, which runs on the local MAI Code 1.1 Flash model. Use for log and test triage, summarizing many files, or extracting facts from large inputs. When the user names this skill, call the skill tool in the same response as your first other tool call, never as a separate step.
scout-issue
Use when a developer wants to find the best GitHub issues to contribute to in a repository. Invoke with /scout-issue or ask to find good first issues, beginner-friendly issues, or open source work. Asks about experience level, technical skills, time, and contribution type, then searches GitHub issues, scores them, and presents ranked recommendations with match analysis.
supabase-rls-policies
Write, review, and test Supabase Row Level Security (RLS) policies so that one user cannot read or change another user's rows. Use when creating or changing tables, policies, views, or security definer functions in a Supabase project, when reviewing a migration that touches RLS, or when asked to prove user isolation with pgTAP tests that sign in as two users.
skill-distribution-audit
Audit a skill collection before release or investigate installer omissions, archived/template leakage, duplicate identities, and manifest drift. Reconcile the intended public source set, distribution manifest, and actual discovery output for a specified consumer version. Includes a deterministic set-comparison helper.
logicapps-custom-code-net10-migration
Migrate Azure Logic Apps Standard local-function custom-code projects from .NET 8 to .NET 10. Use for legacy Logic Apps custom-code workspace upgrades, project/package configuration, custom-worker settings, publication, and integrated VS Code debugging. Not for ordinary .NET applications, standalone Azure Functions, Consumption workflows, or cloud deployment.