1、基于Maven的开发
1.1 先给Eclipse安装Maven插件,可以参考文档点击打开链接,文档中描述的是离线安装插件。我们可以选择在线安装,Eclipse中Help->Eclipse MarketPlace在Find中属于Maven,选择“Maven Integration for Eclipse”插件进行安装。其他设置可以参考链接文档中的设置。
1.2 创建工程时就可以选择Maven Project
1.3 创建完工程后,需要编辑pom.xml,在project标签下面写入如下内容,当你保存时,Maven会自动从远程中心库中下载相关依赖包。
<repositories> <repository> <id>clojars.org</id> <url>http://clojars.org/repo</url> </repository> </repositories> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>org.apache.storm</groupId> <artifactId>storm-core</artifactId> <version>0.9.1-incubating</version> <scope>provided</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.2.1</version> <executions> <execution> <goals> <goal>exec</goal> </goals> </execution> </executions> <configuration> <executable>java</executable> <includeProjectDependencies>true</includeProjectDependencies> <includePluginDependencies>false</includePluginDependencies> <classpathScope>compile</classpathScope> <mainClass>${main.class}</mainClass> </configuration> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <version>2.2.1</version> <configuration> <descriptorRefs> <descriptroRef>jar-with-dependencies</descriptroRef> </descriptorRefs> <archive> <manifest><mainClass></mainClass></manifest> </archive> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
2、基于非Maven的开发
2.1 需要将Storm源码中lib文件夹下的jar包都导入java工程
2.2 如果最后打jar包放到cluster中运行时,不能将这些jar包打进去,因为集群中已经有这些jar包了,会引起jar包冲突而报错。