spring-hadoop.xsd 位於 Spring Hadoop 依賴包的 JAR 內部:
org/springframework/hadoop/config/spring-hadoop.xsd
| 依賴坐標 | JAR 內部路徑 |
|---|---|
org.springframework.data:spring-data-hadoop (舊版) | org/springframework/hadoop/config/spring-hadoop.xsd |
org.springframework.hadoop:spring-hadoop-core (新版模塊化) | org/springframework/hadoop/config/spring-hadoop.xsd |
<dependency>
<groupId>org.springframework.hadoop</groupId>
<artifactId>spring-hadoop-core</artifactId>
<version>2.5.0.RELEASE</version> <!-- 版本根據 Spring Boot/Hadoop 版本選擇 -->
</dependency>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="https://www.springframework.org/schema/beans"
xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xmlns:hdp="https://www.springframework.org/schema/hadoop" <!-- Spring Hadoop 命名空間 -->
xsi:schemaLocation="
https://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
https://www.springframework.org/schema/hadoop https://www.springframework.org/schema/hadoop/spring-hadoop.xsd"> <!-- 這裡引用 xsd -->
<hdp:configuration>
<fs.defaultFS>hdfs://namenode:9000</fs.defaultFS>
<mapreduce.framework.name>yarn</mapreduce.framework.name>
</hdp:configuration>
<hdp:job id="wordCountJob"
input-path="/user/input"
output-path="/user/output"
mapper="com.example.WordCountMapper"
reducer="com.example.WordCountReducer"/>
</beans>
Maven → Reload Project 或 Invalidate Caches / Restart。https://www.springframework.org/schema/hadoop,不要寫成文件路徑。# 解壓 jar 查看
jar xf spring-hadoop-core-2.5.0.RELEASE.jar org/springframework/hadoop/config/spring-hadoop.xsd
cat org/springframework/hadoop/config/spring-hadoop.xsd
spring-hadoop.xsd 在 Spring Hadoop 核心 JAR 的 org/springframework/hadoop/config/ 目錄下。 只要 Maven/Gradle 依賴配置正確,IDE 會自動從 JAR 加載用於 XML 校驗與提示,**無需手動下載放置**。重點檢查依賴坐標、版本兼容性及 XML 命名空間 URI 拼寫。