亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

SpringBoot怎么集成Flink的部署與打包

發布時間:2022-05-20 11:28:21 來源:億速云 閱讀:2569 作者:iii 欄目:開發技術

本文小編為大家詳細介紹“SpringBoot怎么集成Flink的部署與打包”,內容詳細,步驟清晰,細節處理妥當,希望這篇“SpringBoot怎么集成Flink的部署與打包”文章能幫助大家解決疑惑,下面跟著小編的思路慢慢深入,一起來學習新知識吧。

一、SpringBoot集成Flink

其實沒什么特別的,就把Flink依賴的包在pom引入就行了。只是FlinkTask的寫法要小調整下,把相關依賴交給spring管理就行。

然后如果放棄Flink的Dashboard端監控task執行相關信息,那也可以在SpringBoot的啟動類里調用就行,但是可能出現task的相關對象沒有注入,這種都是小問題(實際就是springboot啟動完成再調用,或者通過自動任務調用。也可以在springBoot的入口類用@ComponentScan注解掃描flinkTask所在的目錄)。

實際更瀟灑一點的做法可以將flinkTask的信息存表,通過springBoot的接口調用restfullApi接口,接口里調用task,甚至可以做task的啟停、線程監控(接口里開線程調用task)。

二、FlinkTask寫法調整

@Component
@Slf4j
public class JianGongStopCarTask {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        DataStream<JGParkingLotInfo> dataStream = env.addSource(new JGParkingLotInfoSource());
//       獲取到數據之后轉換格式  此處不做轉換
        SingleOutputStreamOperator<JGParkingLotInfo> jgParkingLotInfoSingleOutputStreamOperator = dataStream.map(jgParkingLotInfo -> jgParkingLotInfo);
        jgParkingLotInfoSingleOutputStreamOperator.addSink(new SinkToMySQL());
        env.execute();
    }
}

PS:

實際就是@Component這個注解,然后這個示例里的JGParkingLotInfoSource、SinkToMySQL類都需要加這個注解。其他就沒有什么調整了,然后如果還有其他依賴沒有,使用hutool的SpringUtil進行get對象就行。

三、打包插件

<plugins>
      <!-- 編譯插件 -->
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
          <encoding>UTF-8</encoding>
        </configuration>
      </plugin>
      <!--  spring boot 項目打包
       <plugin>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-maven-plugin</artifactId>
       </plugin>-->
      <!-- Flink打包方式一 -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>3.3.0</version>
        <configuration>
          <archive>
            <manifest>
              <mainClass>com.easylinkin.dc.olap.JianGongStopCarTask</mainClass>
            </manifest>
          </archive>
          <!-- 打包依賴 -->
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
        <executions>
          <execution>
            <id>make-assembly</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <!-- flink打包方式二
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.3.0</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <createDependencyReducedPom>false</createDependencyReducedPom>
              <artifactSet>
                <excludes>
                  <exclude>com.google.code.findbugs:jsr305</exclude>
                  <exclude>org.slf4j:*</exclude>
                  <exclude>log4j:*</exclude>
                </excludes>
              </artifactSet>
              <filters>
                <filter>
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>module-info.class</exclude>
                    <exclude>META-INF/*.SF</exclude>
                    <exclude>META-INF/*.DSA</exclude>
                    <exclude>META-INF/*.RSA</exclude>
                  </excludes>
                </filter>
              </filters>
              <transformers>
                <transformer
                  implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                  <resource>META-INF/spring.handlers</resource>
                  <resource>reference.conf</resource>
                </transformer>
                <transformer
                  implementation="org.springframework.boot.maven.PropertiesMergingResourceTransformer">
                  <resource>META-INF/spring.factories</resource>
                </transformer>
                <transformer
                  implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                  <resource>META-INF/spring.schemas</resource>
                </transformer>
                <transformer
                  implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                <transformer
                  implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                  <mainClass>com.easylinkin.dc.olap.JianGongStopCarTask</mainClass>
                </transformer>
              </transformers>
            </configuration>
          </execution>
        </executions>
      </plugin>
      -->
      <!-- flink打包方式三
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <mainClass>com.easylinkin.dc.olap.JianGongStopCarTask</mainClass>
              <useUniqueVersions>false</useUniqueVersions>
              <addClasspath>true</addClasspath>
              <classpathPrefix>./lib/</classpathPrefix>
            </manifest>
          </archive>
          <excludes>
            <exclude>module-info.class</exclude>
            <exclude>META-INF/*.SF</exclude>
            <exclude>META-INF/*.DSA</exclude>
            <exclude>META-INF/*.RSA</exclude>
            <exclude>com.google.code.findbugs:jsr305</exclude>
            <exclude>org.slf4j:*</exclude>
            <exclude>log4j:*</exclude>
          </excludes>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.3.0</version>
        <executions>
          <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/lib</outputDirectory>
              <excludeTransitive>false</excludeTransitive>
              <stripVersion>false</stripVersion>
            </configuration>
          </execution>
        </executions>
      </plugin>-->
    </plugins>

除了打成SpringBoot用springboot的插件打包,flinkTask的打包有3種方式,方式三適合lib包提前傳到task指定的依賴存儲目錄。這樣上傳flinkTask就很小。

方式二是官方推薦FlinkTask的打包方式

說一千道一萬就是因為打包的META-INF下的MANIFEST.MF文件的內容有區別。springBoot項目的這個文件有自己的JarLauncher。

SpringBoot怎么集成Flink的部署與打包

FlinkTask的jar這個文件內容

SpringBoot怎么集成Flink的部署與打包

四、Flink的上傳與運行

1、上傳并命令運行

SpringBoot怎么集成Flink的部署與打包

配置好flink環境,命令就是

flink run WordCount.jar

2、Flink管理大屏上傳運行

SpringBoot怎么集成Flink的部署與打包

點擊“Submit”

SpringBoot怎么集成Flink的部署與打包

讀到這里,這篇“SpringBoot怎么集成Flink的部署與打包”文章已經介紹完畢,想要掌握這篇文章的知識點還需要大家自己動手實踐使用過才能領會,如果想了解更多相關內容的文章,歡迎關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

兴文县| 封丘县| 德昌县| 和平区| 麦盖提县| 玉溪市| 孝感市| 浮山县| 陆丰市| 闻喜县| 昆明市| 兴海县| 清水河县| 永春县| 神农架林区| 定结县| 楚雄市| 水城县| 九龙坡区| 江门市| 荆门市| 周宁县| 资阳市| 沾化县| 麻阳| 凌云县| 高碑店市| 敦煌市| 邯郸县| 宜章县| 商水县| 兴海县| 舞钢市| 甘谷县| 舞阳县| 镇坪县| 朝阳县| 木里| 太谷县| 澄迈县| 广河县|