基于Eclipse的Storm应用开发

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包冲突而报错。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值