In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
In this article, the editor introduces in detail "how SpringBoot integrates the deployment and packaging of Flink". The content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how to integrate the deployment and packaging of Flink by SpringBoot" can help you solve your doubts.
First, SpringBoot integrates Flink
It's nothing special, just introduce the packages that Flink depends on into pom. It's just that the way FlinkTask is written should be adjusted slightly, and the relevant dependencies should be handed over to spring management.
Then, if you give up the Dashboard side of Flink to monitor the relevant information of task execution, you can also call it in the startup class of SpringBoot, but there may be no injection of task-related objects, which is a minor problem (in fact, springboot startup is completed and then called, or called through automatic tasks. You can also scan the directory where flinkTask is located with the @ ComponentScan annotation in the entry class of springBoot.
In fact, a more chic approach can store the information of flinkTask in the table, call the restfullApi interface through the interface of springBoot, call task in the interface, and even do the start and stop of task and thread monitoring (open threads call task in the interface).
2. FlinkTask adjustment @ Component@Slf4jpublic class JianGongStopCarTask {public static void main (String [] args) throws Exception {StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment (); DataStream dataStream = env.addSource (new JGParkingLotInfoSource ()); / / after obtaining the data, the conversion format is not converted here SingleOutputStreamOperator jgParkingLotInfoSingleOutputStreamOperator = dataStream.map (jgParkingLotInfo-> jgParkingLotInfo); jgParkingLotInfoSingleOutputStreamOperator.addSink (new SinkToMySQL ()); env.execute ();}}
PS:
This is actually the @ Component annotation, and then the JGParkingLotInfoSource and SinkToMySQL classes in this example need to be annotated. There are no other adjustments, and then if there are no other dependencies, just use hutool's SpringUtil to get the object.
3. Package plug-in maven-compiler-plugin 1.8 UTF-8 org.apache.maven.plugins maven-assembly-plugin 3.3.0 com.easylinkin.dc.olap.JianGongStopCarTask Jar-with-dependencies make-assembly package single
In addition to packaging SpringBoot with plug-ins in springboot, there are three ways to package flinkTask, which are suitable for lib packages to be sent to the dependent storage directory specified by task in advance. This makes the upload flinkTask very small.
The second way is to officially recommend the packaging of FlinkTask.
The reason for this is that the contents of the MANIFEST.MF files under the packaged META-INF are different. This file for the springBoot project has its own JarLauncher.
The contents of the jar file of FlinkTask
IV. Upload and operation of Flink
1. Upload and command to run
To configure the flink environment, the command is
Flink run WordCount.jar
2. Flink manages large screen upload and operation.
Click "Submit"
After reading this, the article "how SpringBoot integrates the deployment and packaging of Flink" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.