QT6(12)3.3.1 Qt元对象系统概述:QObject 类与 QMetaObject 类,类型转换 qobject_cast<T>()。3.3.3 属性系统:帮助文档,宏 Q_PROPERTY

(33)Qt元对象系统概述

在这里插入图片描述

++ QObject 类

在这里插入图片描述

++ 以及

在这里插入图片描述

++老师带咱们学生测试一下

在这里插入图片描述

++谢谢老师

(34)++类型转换 qobject_cast( )

在这里插入图片描述

++ 来自 一言的教导

在这里插入图片描述

(35)3.3.3 属性系统,帮助文档

在这里插入图片描述

++ 用宏 Q_PROPERTY 来定义对象属性

在这里插入图片描述

(36)

谢谢

<?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>com.sxemc</groupId> <artifactId>demo11</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-scala_2.12</artifactId> <version>1.14.0</version> </dependency> <dependency> <groupId>org.apache.flink</groupId> <artifactId>flink-streaming-scala_2.12</artifactId> <version>1.14.0</version> </dependency> <dependency> <groupId>org.apache.flink</groupId> <artifactId>flink-clients_2.12</artifactId> <version>1.14.0</version> </dependency> <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-client</artifactId> <version>3.3.1</version> </dependency> <dependency> <groupId>org.apache.flink</groupId> <artifactId>flink-connector-kafka_2.11</artifactId> <version>1.13.6</version> </dependency> </dependencies> <build> <plugins> <!--指定maven编译的jdk版本和字符集 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.0</version> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> </configuration> </plugin> <!--该插件用于将 Scala代码编译成 class文件 --> <plugin> <groupId>net.alchim31.maven</groupId> <artifactId>scala-maven-plugin</artifactId> <version>3.2.0</version> <executions> <execution> <goals> <goal>compile</goal> <goal>testCompile</goal> </goals> <configuration> <args> <arg>-dependencyfile</arg> <arg>${project.build.directory}/.scala_dependencies</arg> </args> </configuration> </execution> </executions> </plugin> <!-- 将依赖的jar包打包到当前jar包 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.1.1</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <filters> <filter> <artifact>*:*</artifact> <excludes> <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.ManifestResourceTransformer"> <mainClass></mainClass> </transformer> </transformers> </configuration> </execution> </executions> </plugin> </plugins> </build> </project>帮忙改一下
09-20
# 普通文本型问题解答 你的 `pom.xml` 存在几个关键问题: 1. **Scala 版本混用**:`flink-*.2.12` `flink-connector-kafka_2.11` 不兼容; 2. **Flink Kafka Connector 版本不一致**:使用了 `1.13.6`,而其他 Flink 组件是 `1.14.0`; 3. **mainClass 未填写**; 4. 缺少必要的序列化支持库(如 JSON、SimpleStringSchema)。 --- ### ✅ 修改后的完整 `pom.xml` ```xml <?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>com.sxemc</groupId> <artifactId>demo11</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> <!-- 统一版本控制 --> <flink.version>1.14.0</flink.version> <scala.binary.version>2.12</scala.binary.version> </properties> <dependencies> <!-- Flink Scala API --> <dependency> <groupId>org.apache.flink</groupId> <artifactId>flink-scala_${scala.binary.version}</artifactId> <version>${flink.version}</version> </dependency> <!-- Flink Streaming --> <dependency> <groupId>org.apache.flink</groupId> <artifactId>flink-streaming-scala_${scala.binary.version}</artifactId> <version>${flink.version}</version> </dependency> <!-- Flink Clients --> <dependency> <groupId>org.apache.flink</groupId> <artifactId>flink-clients_${scala.binary.version}</artifactId> <version>${flink.version}</version> </dependency> <!-- Hadoop Client --> <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop-client</artifactId> <version>3.3.1</version> </dependency> <!-- ✅ 修复点1:统一为 Scala 2.12 + Flink 1.14.0 的 Kafka Connector --> <dependency> <groupId>org.apache.flink</groupId> <artifactId>flink-connector-kafka_${scala.binary.version}</artifactId> <version>${flink.version}</version> </dependency> <!-- ✅ 修复点2:添加 SimpleStringSchema 所需依赖 --> <dependency> <groupId>org.apache.flink</groupId> <artifactId>flink-json</artifactId> <version>${flink.version}</version> </dependency> <!-- ✅ 可选:解决 SLF4J 警告 --> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>1.7.36</version> </dependency> </dependencies> <build> <plugins> <!-- 指定编译 JDK 版本 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>8</source> <target>8</target> <encoding>UTF-8</encoding> </configuration> </plugin> <!-- Scala 编译插件 --> <plugin> <groupId>net.alchim31.maven</groupId> <artifactId>scala-maven-plugin</artifactId> <version>4.5.6</version> <executions> <execution> <goals> <goal>compile</goal> <goal>testCompile</goal> </goals> </execution> </executions> </plugin> <!-- Shade 插件打包成 fat jar --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-shade-plugin</artifactId> <version>3.4.1</version> <executions> <execution> <phase>package</phase> <goals> <goal>shade</goal> </goals> <configuration> <filters> <filter> <artifact>*:*</artifact> <excludes> <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.ManifestResourceTransformer"> <!-- ✅ 修复点3:请替换为你主的全路径 --> <mainClass>KafkaForwardJob</mainClass> </transformer> </transformers> <!-- 避免 Kafka 冲突 --> <relocations> <relocation> <pattern>org.apache.kafka</pattern> <shadedPattern>shaded.org.apache.kafka</shadedPattern> </relocation> </relocations> </configuration> </execution> </executions> </plugin> </plugins> </build> </project> ``` --- ### 🔧 修改说明总结 | 问题 | 原因 | 修正方式 | |------|------|-----------| | ❌ `flink-connector-kafka_2.11` + `2.12` 混用 | Scala 二进制不兼容 | 改为 `${scala.binary.version}` 即 `2.12` | | ❌ Kafka Connector 版本为 `1.13.6` | 其他 Flink 模块版本不一致 | 统一升级到 `1.14.0` | | ❌ 缺少 `flink-json` | `SimpleStringSchema` 等找不到 | 添加依赖 | | ⚠️ 日志警告 | 无日志实现 | 添加 `slf4j-simple` 或配置 log4j | | ❌ `mainClass` 为空 | 提交任务时报错 | 填写你的主名,例如 `KafkaForwardJob` | | ⚠️ 插件版本过旧 | 如 maven-shade-plugin 3.1.1 | 升级到最新稳定版 | --- ### ✅ 使用建议 1. 将 `<mainClass>` 替换为你的实际主全名,例如: ```xml <mainClass>com.sxemc.KafkaForwardJob</mainClass> ``` 2. 执行打包命令: ```bash mvn clean package ``` 3. 使用生成的 JAR 提交任务: ```bash flink run -c com.sxemc.KafkaForwardJob target/demo11-1.0-SNAPSHOT.jar ``` ✅ 完成后即可避免 `NoSuchMethodError` 和 `descriptors` 报错,顺利运行 Flink Kafka 数据转发程序。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zhangzhangkeji

谢谢支持

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值