【问题标题】:Cannot find class-name-1.0-SNAPSHOT-jar-with-dependencies.jar [duplicate]找不到 class-name-1.0-SNAPSHOT-jar-with-dependencies.jar [重复]
【发布时间】:2015-11-02 15:24:23
【问题描述】:

我是maven新手,我试过用这个命令

mvn package 

结果是没有包含dependencies.jar的文件

我可以分享 pom 的哪一部分?因为太长了,这里发不出来

<plugins>
    <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
            <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
            </descriptorRefs>
            <archive>
                <manifest>
                    <mainClass>trident.myclass</mainClass>
                    <!-- <mainClass>crawler.Crawler</mainClass> -->
                </manifest>
            </archive>
        </configuration>
        <executions>
            <execution>
                <id>my-topology</id>
                <phase>package</phase>
                <goals>
                    <goal>jar</goal>
                </goals>
                <configuration>
                    <includes>
                        <include>/home/st/workspace/my-project/target/classes/trident/myclass.class
                        </include>
                    </includes>
                </configuration>
            </execution>
        </executions>
    </plugin>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
            <source>1.6</source>
            <target>1.6</target>
        </configuration>
    </plugin>
</plugins>

执行此命令时的上一个错误

mvn compile exec:java -Dexec.classPathScope=compile -Dexec.mainClass=trident.myproject

知道了

java.lang.NoClassDefFoundError: storm/trident/state/StateFactory
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
at java.lang.Class.getMethod0(Class.java:2670)
at java.lang.Class.getMethod(Class.java:1603)
at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:285)

然后换成

<scope>provided</scope>

到

<scope>compile</scope>

然后尝试提交拓扑时出现此错误

Exception in thread "main" java.lang.RuntimeException: Found multiple defaults.yaml resources. You're probably bundling the Storm jars with your topology jar.
  at backtype.storm.utils.Utils.findAndReadConfigFile(Utils.java:115)
  at backtype.storm.utils.Utils.readDefaultConfig(Utils.java:135)
  at backtype.storm.utils.Utils.readStormConfig(Utils.java:155)
  at backtype.storm.StormSubmitter.submitTopology(StormSubmitter.java:61)
  at backtype.storm.StormSubmitter.submitTopology(StormSubmitter.java:40)
  at trident.myproject.main(myproject.java:288)

并通过在 maven 插件中将程序集更改为 jar 并包含主类的路径来解决

最后我不想更改 pom 中的任何内容,因为项目在我第一次运行时,运行成功,没有任何错误

【问题讨论】:

  • 显示 pom 、程序集插件和/或 assembly.xml
  • 为什么不投票我说 pom 文件太长了,因为我是新人,所以我说我可以分享哪个部分!!!
  • 您的问题不完整,请使用gist.github.com分享更多代码
  • 这是第一次听说这个网站 gist.github.com ,所以谢谢你,但你可以先给我建议,然后再投反对票!!!如果我没有采纳你的建议,你可以投反对票!
  • @user3188912 当你的问题得到改进时,我可以投票赞成。请张贴整个pom.xml。其他热门网站:pastebin.com

标签: java maven apache-storm


【解决方案1】:

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2012-01-26
  • 1970-01-01
  • 1970-01-01
  • 2015-03-24
  • 1970-01-01
  • 2014-12-23
  • 1970-01-01
  • 2022-10-14
相关资源
最近更新 更多