在storm 2.2.1 java idea实现基本demo的基础上本地开发环境执行成功后需要提交到storm的测试或生产环境此时需要将项目打包成jar然后再进行提交。
1. 配置pom.xml文件打包成jar
打包需要指定打包类型和名称。
jarstorm-helloworld
由于运行环境已经有依赖包了所以不需要storm-core所以需要修改scope。
org.apache.stormstorm-core2.2.1provided
添加打包组件
maven-assembly-pluginjar-with-dependenciescom.demo.storm.ExclamationTopology
执行打包命令
mvn assembly:assembly
在target找到storm-helloworld-1.0-SNAPSHOT-jar-with-dependencies.jar这就是可以提交到storm环境进行执行的jar包。
2. 执行jar包提交
D:\sdks\apache-storm-2.2.1\bin>storm.py jar storm-helloworld-1.0-SNAPSHOT-jar-with-dependencies.jar com.demo.storm.ExclamationTopology ExclamationTestRunning: D:\sdks\jdk1.8.0_191\bin\java.exe -client -Ddaemon.name -Dstorm.options -Dstorm.homeD:\sdks\apache-storm-2.2.1 -Dstorm.log.dirD:\sdks\apache-storm-2.2.1\logs -Djava.library.path/usr/local/lib:/opt/local/lib:/usr/lib:/usr/lib64 -Dstorm.conf.file -cp D:\sdks\apache-storm-2.2.1\*;D:\sdks\apache-storm-2.2.1\lib-worker\*;D:\sdks\apache-storm-2.2.1\extlib\*;storm-helloworld-1.0-SNAPSHOT-jar-with-dependencies.jar;D:\sdks\apache-storm-2.2.1\conf;D:\sdks\apache-storm-2.2.1\bin; -Dstorm.jarstorm-helloworld-1.0-SNAPSHOT-jar-with-dependencies.jar -Dstorm.dependency.jars -Dstorm.dependency.artifacts{} com.demo.storm.ExclamationTopology ExclamationTest13:23:00.263 [main] INFO o.a.s.StormSubmitter - Generated ZooKeeper secret payload for MD5-digest: -8787587062738558446:-808387676353632202913:23:00.314 [main] WARN o.a.s.v.ConfigValidation - task.heartbeat.frequency.secs is a deprecated config please see class org.apache.storm.Config.TASK_HEARTBEAT_FREQUENCY_SECS for more information.13:23:00.392 [main] INFO o.a.s.u.NimbusClient - Found leader nimbus : DESKTOP-O93E7VQ:662713:23:00.393 [main] INFO o.a.s.s.a.ClientAuthUtils - Got AutoCreds []13:23:00.422 [main] INFO o.a.s.StormSubmitter - Uploading dependencies - jars...13:23:00.423 [main] INFO o.a.s.StormSubmitter - Uploading dependencies - artifacts...13:23:00.423 [main] INFO o.a.s.StormSubmitter - Dependency Blob keys - jars : [] / artifacts : []13:23:00.437 [main] INFO o.a.s.StormSubmitter - Uploading topology jar storm-helloworld-1.0-SNAPSHOT-jar-with-dependencies.jar to assigned location: D:\sdks\apache-storm-2.2.1\storm-local\nimbus\inbox/stormjar-4c0ffedd-8447-4d5f-89a1-1632e5a9f88c.jarStart uploading file storm-helloworld-1.0-SNAPSHOT-jar-with-dependencies.jar to D:\sdks\apache-storm-2.2.1\storm-local\nimbus\inbox/stormjar-4c0ffedd-8447-4d5f-89a1-1632e5a9f88c.jar (4890 bytes)[] 4890 / 4890File storm-helloworld-1.0-SNAPSHOT-jar-with-dependencies.jar uploaded to D:\sdks\apache-storm-2.2.1\storm-local\nimbus\inbox/stormjar-4c0ffedd-8447-4d5f-89a1-1632e5a9f88c.jar (4890 bytes)13:23:00.465 [main] INFO o.a.s.StormSubmitter - Successfully uploaded topology jar to assigned location: D:\sdks\apache-storm-2.2.1\storm-local\nimbus\inbox/stormjar-4c0ffedd-8447-4d5f-89a1-1632e5a9f88c.jar13:23:00.465 [main] INFO o.a.s.StormSubmitter - Submitting topology ExclamationTest in distributed mode with conf {"storm.zookeeper.topology.auth.scheme":"digest","storm.zookeeper.topology.auth.payload":"-8787587062738558446:-8083876763536322029","topology.workers":3,"topology.debug":false}13:23:00.655 [main] INFO o.a.s.StormSubmitter - Finished submitting topology: ExclamationTest
3. 查看运行状态信息
http://localhost:8080/topology.html?idExclamationTest-1-1643347380