IntelliJ提示URI未注册与xsi:schemaLocation属性不允许报错如何解决

报错解决方案
这两类报错均由IntelliJ IDEA对pom.xml的XML Schema校验不通过导致,按以下步骤排查即可解决:
1. 修正xsi:schemaLocation拼写错误
Attribute xsi: schemaLocation is not allowed here报错90%以上由空格问题导致,检查pom.xml根节点的schema声明,确保xsi:和schemaLocation之间没有多余空格,标准根节点配置参考如下:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <!-- 其余配置 --> </project>
同时检查所有URI地址拼写无错漏。
2. 手动忽略未注册的URI
针对URI is not registered报错,按以下路径操作:
- 打开IDEA设置:
File > Settings > Languages & Frameworks > Schemas and DTDs - 找到右侧
Ignored Schemas and DTDs区域,点击加号,将报错提示中提到的未注册URI粘贴进去 - 点击确定保存设置
3. 刷新项目缓存
如果完成前两步后仍有报错,执行缓存清理操作:
- 点击IDEA右侧Maven面板的刷新图标,选择
Reload All Maven Projects重新加载依赖 - 若问题仍存在,打开
File > Invalidate Caches...,勾选Clear file system cache and local history,点击Invalidate and Restart重启IDEA即可
操作完成后重新构建项目即可恢复正常。
内容的提问来源于stack exchange,提问作者Anonymous
相关产品推荐
相关产品推荐

