具有intellij想法的风暴启动者,maven项目找不到类 [英] storm-starter with intellij idea,maven project could not find class

查看:345
本文介绍了具有intellij想法的风暴启动者,maven项目找不到类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是风暴和intellij想法的初学者,当我将风暴启动器(apache-storm-0.9.5.zip)导入intellij idea(14 CE OS)时,一切都还可以,但是当我运行ExclamationTopology时,出现问题如下:

I'm beginner of storm and intellij idea,when I import storm-starter(apache-storm-0.9.5.zip) to intellij idea(14 CE OS),everything is OK,but when I run the "ExclamationTopology" ,a problem appears as follow:

Exception in thread "main" java.lang.NoClassDefFoundError: backtype/storm/topology/IRichSpout
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Class.java:264)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:122)
Caused by: java.lang.ClassNotFoundException: backtype.storm.topology.IRichSpout
	at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 3 more

Process finished with exit code 1

这个界面来自storm-core,但这个maven托管的jar在我的库中
为什么这是否发生了??

this interface is from storm-core,but this maven managed jar is in my library Why does this happened..?

推荐答案

Strom已经在服务器端需要jar了。因此,如果查看pom.xml,您会发现类似于:
https://github.com/apache/storm/blob/master/examples/storm-starter/pom.xml

Strom already has required jar on the server side. So, if look into the pom.xml you find something similar to: https://github.com/apache/storm/blob/master/examples/storm-starter/pom.xml

<dependency>
  <groupId>org.apache.storm</groupId>
  <artifactId>storm-core</artifactId>
  <version>${project.version}</version>
  <!-- keep storm out of the jar-with-dependencies -->
  <scope>provided</scope>
</dependency>

提供的范围仅适用于编译和测试类路径。因为它你的项目编译,但在运行时失败,但有异常:java.lang.NoClassDefFoundError。

The provided scope is only available on the compilation and test classpath. Because of it your project compiles, but then fails in the runtime with exception : java.lang.NoClassDefFoundError.

请在你的pom.xml中注释范围行并更新maven依赖关系来解决这个问题。它应该看起来像:

Please, comment the scope line in your pom.xml and update maven dependencies to solve this problem. It should looks like:

<dependency>
  <groupId>org.apache.storm</groupId>
  <artifactId>storm-core</artifactId>
  <version>${project.version}</version>
  <!-- keep storm out of the jar-with-dependencies -->
  <!-- <scope>provided</scope> -->
</dependency>

这篇关于具有intellij想法的风暴启动者,maven项目找不到类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆