解决IDEA打包Scala项目未包含class文件

问题发现:

<dependencies>
        <dependency>
            <groupId>org.apache.sparkgroupId>
            <artifactId>spark-core_2.12artifactId>
            <version>3.0.0version>
        dependency>
dependencies>

当pom.xml只加入spark依赖打包后的jar包的文件内容如下:
解决IDEA打包Scala项目未包含class文件_第1张图片
jar包中并未包含scala相关的文件信息。

解决:
在pom.xml加入:

<build>
        <plugins>
            <plugin>
                <groupId>net.alchim31.mavengroupId>
                <artifactId>scala-maven-pluginartifactId>
                <version>3.2.2version>
                <executions>
                    <execution>
                        <id>scala-compile-firstid>
                        <phase>process-resourcesphase>
                        <goals>
                            <goal>add-sourcegoal>
                            <goal>compilegoal>
                        goals>
                    execution>
                    <execution>
                        <id>scala-test-compileid>
                        <phase>process-test-resourcesphase>
                        <goals>
                            <goal>testCompilegoal>
                        goals>
                    execution>
                executions>
            plugin>
        plugins>
build>

再次执行打包选项,此时生成的jar包中已经包含了所编写Scala的class文件
解决IDEA打包Scala项目未包含class文件_第2张图片

你可能感兴趣的:(Scala,学习,idea,scala)