java - 错误:无法找到或加载主类:Scala IDE/Spark
问题描述
我正在使用 scala-ide 构建一个 spark 应用程序。在从 Eclipse 运行我的课程时,没有生成任何类文件,并且它让我 -
Error: Could not find or load main class
当我通过 maven 构建我的项目时,我的类文件正在生成并且程序也在 eclipse 中执行。但是在进行开发的同时也运行这项工作,我不能一次又一次地使用 maven 进行构建。我的 pom.xml 看起来像 -
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<encoding>UTF-8</encoding>
<scala.tools.version>2.11</scala.tools.version>
<scala.version>2.11.11</scala.version>
</properties>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.spark</groupId>
<artifactId>spark-core_2.11</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>2.7.5</version>
<scope>provided</scope>
</dependency>
<!-- <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId>
<version>2.4.4</version> </dependency> -->
</dependencies>
<build>
<!-- <sourceDirectory>src/main/scala</sourceDirectory> <testSourceDirectory>src/test/scala</testSourceDirectory> -->
<plugins>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<executions>
<execution>
<id>scala-compile-first</id>
<phase>process-resources</phase>
<goals>
<goal>add-source</goal>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>scala-test-compile</id>
<phase>process-test-resources</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<!-- Additional configuration. -->
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
我检查了我的版本是否正确(如果不是这样,maven 构建会失败),而且我的目录结构似乎是正确的-
任何帮助将不胜感激。
解决方案
我认为您的构建路径中有一些错误:Right click in project -> Build Path -> Configure Build Path
推荐阅读
- perl - Perl 中的 OS 页面对齐分配
- azure - Docker 上的 Azure CosmosDB 模拟器不生成证书
- javascript - ReactJS 类组件使用 contenteditable 元素渲染 array.map
- javascript - 注册表单上的 asp.net + asp:button、HTML 和 Javascript 存在问题
- javascript - Symfony 3/4:通过 AJAX 从数据库中删除表行
- powershell - 使用 Where-Object 打开文件
- firebase - 在特定时间对谷歌通知的操作
- ios - 旧项目停止使用最新的模拟器更新进行构建
- python - Pandas:用于条目的优先级消除重复值
- jquery - 如何使用 jQuery 定位嵌套在另一个元素的兄弟标签中的元素