java.io.FileNotFoundException:./src/main/resources/config.properties(无此文件或目录)在spark-submit中

时间:2019-05-23 05:16:14

标签: apache-spark classpath

我以

的方式获取配置
 in = instance.getClass().getResourceAsStream("/config.properties");
 props.load(in);

在我的win7想法中,它工作正常,当以spark-submit的方式运行时,遇到了一个例外:

19/05/23 12:57:40 ERROR yarn.ApplicationMaster: User class threw exception: java.io.FileNotFoundException: ./src/main/resources/config.properties (no such file or directory)
java.io.FileNotFoundException: ./src/main/resources/config.properties (no such file or directory)

我的pom.xml这样

<resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
        <plugins>
            <!-- build-helper-maven-plugin, 设置多个源文件夹 -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.8</version>
                <executions>
                    <execution>
                        <id>add-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${basedir}/src/main/scala</source>
                                <source>${basedir}/src/main/java</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

我的项目是这样的: enter image description here

0 个答案:

没有答案