找不到class-name-1.0-SNAPSHOT-jar-with-dependencies.jar

时间:2015-11-02 15:24:23

标签: java maven apache-storm

我是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中的任何内容,因为我第一次运行该项目,成功运行没有任何错误

1 个答案:

答案 0 :(得分:1)