您的位置:首页 > 健康 > 美食 > Flink ui 本地flink ui 报错 {“errors“:[“Not found: /“]}

Flink ui 本地flink ui 报错 {“errors“:[“Not found: /“]}

2024/12/23 1:29:44 来源:https://blog.csdn.net/haohaixingyun/article/details/140313041  浏览:    关键词:Flink ui 本地flink ui 报错 {“errors“:[“Not found: /“]}

在学习flink 的过程中,伊始的flink 版本是1.17.2 报题目的错误 ,百思不得其解,尝试更替了1.19.1 然后就成功了 ,期间未做任何的修改 。

ui 默认地址 : http://localhost:8081 

pom 文件 如下 

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><groupId>org.example</groupId><artifactId>TT</artifactId><version>1.0-SNAPSHOT</version><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><dependencies><dependency><groupId>org.apache.flink</groupId><artifactId>flink-streaming-java</artifactId><version>1.19.1</version></dependency><dependency><groupId>org.apache.flink</groupId><artifactId>flink-clients</artifactId><version>1.19.1</version></dependency><dependency><groupId>org.apache.flink</groupId><artifactId>flink-connector-datagen</artifactId><version>1.19.1</version></dependency><dependency><groupId>org.apache.flink</groupId><artifactId>flink-table-api-java-bridge</artifactId><version>1.19.1</version></dependency><!--在本地的集成开发环境里运行Table API和SQL的支持--><dependency><groupId>org.apache.flink</groupId><artifactId>flink-table-planner-loader</artifactId><version>1.19.1</version></dependency><dependency><groupId>org.apache.flink</groupId><artifactId>flink-table-runtime</artifactId><version>1.19.1</version></dependency><dependency><groupId>org.apache.flink</groupId><artifactId>flink-runtime-web</artifactId><version>1.19.1</version></dependency><dependency><groupId>org.slf4j</groupId><artifactId>slf4j-log4j12</artifactId><version>1.7.25</version></dependency><dependency><groupId>org.apache.flink</groupId><artifactId>flink-java</artifactId><version>1.19.1</version></dependency></dependencies></project>

Java 类 ,flink 环境的初始化有很多种,这个只是本地环境的一种 :

package com.org.flinkBase;import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.ProcessFunction;
import org.apache.flink.util.Collector;public class FlinkDemoCumulateUI {public static void main(String[] args) throws Exception{Configuration conf = new Configuration();//conf.setString(RestOptions.BIND_PORT,"8081-8089");StreamExecutionEnvironment env = StreamExecutionEnvironment.createLocalEnvironmentWithWebUI(conf);// 产生一个初始数据流,这里我们使用一个简单的集合作为数据源DataStream<String> initialStream = env.fromElements("Hello", "Flink", "World","Hello", "Flink", "World");// 定义一个 Map 算子,将流中的每个字符串转换为大写DataStream<String> transformedStream = initialStream.map(new MapFunction<String, String>() {@Overridepublic String map(String value) throws Exception {return value.toUpperCase();}});// 使用 ProcessFunction 增加处理时间transformedStream.keyBy((String value) -> value) // 这里使用每个字符串本身作为 key,只是为了演示.process(new ProcessFunction<String, String>() {@Overridepublic void processElement(String value, Context ctx, Collector<String> out) throws Exception {// 模拟处理时间,例如,延迟5秒Thread.sleep(85000);out.collect(value);}}).print(); // 输出转换后的数据流env.execute("Java Flink Job with Map Operator");}}

Ui  结果:

感悟:

柳暗花明又一村,死磕到底的勇气,不断试错,新时代的爱迪生,努力寻找答案

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com