我以
的方式获取配置 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>