【问题标题】:Unable to get external class files of scala in build jar eclipse无法在构建 jar eclipse 中获取 scala 的外部类文件
【发布时间】:2018-04-12 09:23:27
【问题描述】:

我正在尝试从使用 redis 库的 scala spark 项目创建一个可运行的 jar。因此,我从 Scala-Redis github 项目中创建了类,并在我目前的代码中使用了该包。该项目通过 Eclipse 界面构建和运行,但是当我尝试创建 jar - 我收到 classNotfound 异常。检查时发现 redis 类不包含在构建 jar 中。我也在使用其他外部罐子。它们包含在构建中,但不包含在 redis 中。我哪里出错或失踪了?

Pom.xml 是:-

           <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-assembly-plugin</artifactId>
            <executions>
                <execution>
                    <id>package-jar-with-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <appendAssemblyId>true</appendAssemblyId>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                        <archive>
                            <manifest>
                                <mainClass>com.spark.ReCalculateOdo</mainClass>
                            </manifest>
                        </archive>
                    </configuration>
                </execution>
            </executions>
        </plugin>

我已将类文件夹包含在构建路径运行配置中。请给点建议,谢谢,

【问题讨论】:

    标签: scala eclipse-plugin sbt executable-jar maven-assembly-plugin


    【解决方案1】:

    我尝试了一个技巧,它奏效了。我不知道为什么会发生这种情况,但它适用于我的情况。所以这个想法是,每当你想要一个 jar 时,只需清理构建项目,然后在 eclipse 中运行项目,现在创建 maven 安装。您将在项目的目标文件夹中找到一个 jar。所以,现在你可以在命令行中使用它了。它会起作用的。

    谢谢,

    【讨论】:

      猜你喜欢
      • 2016-11-29
      • 2011-09-11
      • 1970-01-01
      • 2012-07-25
      • 1970-01-01
      • 1970-01-01
      • 2011-04-25
      • 1970-01-01
      • 2011-04-15
      相关资源
      最近更新 更多