docs: add doc _Fix IntelliJ IDEA Missing Spring Boot application.yaml Code Completion_

This commit is contained in:
2026-05-26 16:32:40 +08:00
parent b4c9232d78
commit 59d7a3042a
3 changed files with 115 additions and 0 deletions
+3
View File
@@ -12,3 +12,6 @@ doc_build/
.vscode/* .vscode/*
!.vscode/extensions.json !.vscode/extensions.json
.idea .idea
# Claude Code
.claude/settings.local.json
@@ -0,0 +1,56 @@
---
title: Fix IntelliJ IDEA Missing Spring Boot application.yaml Code Completion
tags:
- intellij-idea
- spring-boot
- yaml
- schema-validation
- troubleshooting
author:
name: Zihlu Wang
email: real@zihluwang.me
---
Recently, while developing a Spring Boot project in IntelliJ IDEA, I noticed that the smart code completion for `application.yaml` and `application.yml` had suddenly vanished. Worse, the editor was flooded with warnings reading:
> Schema validation: Missing required property 'kind' = 'Application'
## The Symptom
When opening any `application.yaml` or `application.yml` under `src/main/resources/`, IDEA would treat it as an Enonic XP application descriptor rather than a Spring Boot configuration file. All Spring-specific property hints were gone, replaced by schema validation errors complaining about a missing `kind` property — a field that has nothing to do with Spring Boot.
Restarting IDEA, invalidating caches, and re-importing the project made no difference. The problem persisted across restarts.
## The Quick Fix
After some digging, I found the culprit. IDEA downloads JSON Schemas from remote sources (specifically, the [SchemaStore](https://www.schemastore.org/) catalogue) and uses them to validate configuration files. A recent schema update had introduced a `fileMatch` pattern that was too aggressive.
To disable this behaviour immediately:
1. Open **Settings** (Ctrl+Alt+S / Cmd+,)
2. Navigate to **Languages & Frameworks → Schemas and DTDs → Remote JSON Schemas**
3. Uncheck **Allow downloading JSON Schemas from remote sources**
4. Click **OK**
Your Spring Boot configuration hints will return instantly.
## Root Cause
The real culprit traces back to **19 May 2026**, when a developer from [Enonic](https://www.enonic.com/) submitted a pull request to the SchemaStore repository ([PR #5704](https://github.com/SchemaStore/schemastore/pull/5704)) that added the Enonic XP application descriptor schema. The schema's `fileMatch` property was set to:
```json
"fileMatch": [
"**/src/main/resources/application.yaml",
"**/src/main/resources/application.yml"
]
```
This pattern is far too broad — it matches **every** `application.yaml` and `application.yml` placed under `src/main/resources/`, which happens to be exactly where Spring Boot projects store their configuration files. Once this schema was merged into SchemaStore, any IntelliJ IDEA instance with remote JSON schema downloading enabled would fetch it and begin validating Spring Boot configs against the Enonic XP schema.
The developer has since acknowledged the issue and submitted a follow-up fix ([PR #5711](https://github.com/SchemaStore/schemastore/pull/5711)) to tighten the `fileMatch` patterns. As of writing, the fix has not yet been merged into SchemaStore.
## Why This Matters
SchemaStore is a community-maintained catalogue of JSON Schemas used by many editors (VS Code, IntelliJ IDEA, Neovim, etc.) to provide validation and autocompletion for common configuration files. When a schema in this catalogue declares overly broad matching rules, it affects users across all platforms and editors — not just IDEA.
For Spring Boot developers, the takeaway is simple: if your `application.yaml` hints disappear overnight, check what schema your IDE thinks the file belongs to. It might not be Spring Boot at all.
@@ -0,0 +1,56 @@
---
title: 修复 IntelliJ IDEA 中 Spring Boot 的 application.yaml 智能提示消失问题
tags:
- intellij-idea
- spring-boot
- yaml
- schema-validation
- troubleshooting
author:
name: Zihlu Wang
email: real@zihluwang.me
---
最近在使用 IDEA 开发 Spring Boot 项目时,我发现 `application.yaml``application.yml` 的智能代码提示突然消失了。更糟糕的是,编辑器中充满了如下警告:
> `Schema validation: Missing required property 'kind' = 'Application'`
## 症状
打开 `src/main/resources/` 下的 `application.yaml``application.yml` 文件时,IDEA 会将其视为 Enonic XP 应用描述文件,而非 Spring Boot 配置文件。所有 Spring 特有的属性提示全部消失,取而代之的是一堆要求填写 `kind` 属性的 Schema 校验错误——这个字段与 Spring Boot 毫无关系。
重启 IDEA、清除缓存、重新导入项目都无济于事,问题依旧存在。
## 快速修复
经过一番排查,我找到了罪魁祸首。IDEA 会从远程源(具体来说是 [SchemaStore](https://www.schemastore.org/) 目录)下载 JSON Schema,并用它们来校验配置文件。最近的一次 Schema 更新引入了一个匹配范围过大的 `fileMatch` 模式。
要立即禁用此行为:
1. 打开 **Settings**Ctrl+Alt+S / Cmd+,
2. 导航至 **Languages & Frameworks → Schemas and DTDs → Remote JSON Schemas**
3. 取消勾选 **Allow downloading JSON Schemas from remote sources**
4. 点击 **OK**
Spring Boot 的配置提示会立刻恢复。
## 根本原因
事情的根源要追溯到 **2026 年 5 月 19 日**,一位来自 [Enonic](https://www.enonic.com/) 的开发者向 SchemaStore 仓库提交了一个 PR[PR #5704](https://github.com/SchemaStore/schemastore/pull/5704)),添加了 Enonic XP 应用描述文件的 Schema。该 Schema 的 `fileMatch` 属性被设置为:
```json
"fileMatch": [
"**/src/main/resources/application.yaml",
"**/src/main/resources/application.yml"
]
```
这个匹配模式过于宽泛——它匹配了 **所有** 位于 `src/main/resources/` 下的 `application.yaml``application.yml` 文件,而这正是 Spring Boot 项目存放配置文件的位置。一旦该 Schema 被合并到 SchemaStore 中,任何启用了远程 JSON Schema 下载功能的 IntelliJ IDEA 都会拉取它,并开始用 Enonic XP 的 Schema 来校验 Spring Boot 的配置。
该开发者已意识到问题,并提交了后续修复 PR([PR #5711](https://github.com/SchemaStore/schemastore/pull/5711))来收紧 `fileMatch` 匹配规则。截至本文撰写时,该修复尚未被 SchemaStore 合并。
## 为什么这很重要
SchemaStore 是一个由社区维护的 JSON Schema 目录,被许多编辑器(VS Code、IntelliJ IDEA、Neovim 等)用来为常见配置文件提供校验和自动补全功能。当该目录中的某个 Schema 声明了过于宽泛的匹配规则时,会影响到所有平台、所有编辑器的用户——不仅仅是 IDEA。
对于 Spring Boot 开发者来说,结论很简单:如果你的 `application.yaml` 提示一夜之间消失了,先检查一下你的 IDE 认为该文件属于哪个 Schema,它可能根本不是 Spring Boot。