在 Win10 中,在 IntelliJ 中,此路徑(“C:/hive/Orders_[0-9]*.csv”)作為獨立的 java Spark 作業(yè)運行時效果很好。但不作為 Spring Boot Spark 工作。似乎 Spring Boot 未檢測到本機文件系統(tǒng)。不知道如何解決這個問題。Dataset<Row> DF1 = spark .read().format("csv") .option("header", "true") .option("delimiter", "\t") .load("C:/hive/Orders_[0-9]*.csv");錯誤:Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.2019-09-04 21:59:27.701 ERROR [omni-ods-migration,,,] 8216 --- [ main] o.s.boot.SpringApplication : Application startup failedorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'odsMigrationService': Invocation of init method failed; nested exception is java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.NativeIO$Windows.access0(Ljava/lang/String;I)Z at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:137) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:409) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1620) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:555) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)當(dāng)給出確切的文件名的路徑時,下面的代碼在 Spring Boot 中也能正常工作。Dataset<Row> DF1 = spark .read().format("csv") .option("header", "true") .option("delimiter", "\t") .load("C:/hive/Orders_000001.csv");如何解決這個問題?
1 回答

收到一只叮咚
TA貢獻(xiàn)1821條經(jīng)驗 獲得超5個贊
這是一個可能的解決方案
從https://github.com/cdarlint/winutils下載適用于 Windows 的 Hadoop 文件
提取文件(例如 C:\hadoop)。確保目錄結(jié)構(gòu)與此類似
C:\hadoop\bin\winutils.exe
將環(huán)境變量設(shè)置
HADOOP_HOME
為C:\hadoop
將 Hadoop 添加到 Path 環(huán)境變量:
%HADOOP_HOME%\bin
復(fù)制
hadoop.dll
到Windows\System32
(可能不需要)重啟系統(tǒng)
Java 應(yīng)用程序特定:將其添加到 main 方法中:
System.setProperty ("hadoop.home.dir", "C:/hadoop/" );
?System.load ("C:/hadoop/bin/hadoop.dll");
添加回答
舉報
0/150
提交
取消