flink基于Aspectj和Classpath的二开方式

有些时候需要对flink进行二次开发,但是又不想维护整个flink项目(flink项目的代码比较多)。

以下给出maven中pom的配置:

XML 复制代码
<build>
        <finalName>dataprocess</finalName>
        <plugins>
            <!-- AspectJ 编译插件 -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>aspectj-maven-plugin</artifactId>
                <version>${aspectj-maven-plugin.version}</version>
                <configuration>
                    <complianceLevel>${java.version}</complianceLevel>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <verbose>true</verbose>
                    <Xlint>ignore</Xlint>
                    <encoding>UTF-8</encoding>
                    <showWeaveInfo>true</showWeaveInfo>
                    <sources>
                        <source>
                            <basedir>${project.basedir}/../dataprocess-flink/src/main/java/com/dataprocess/flink/aspect</basedir>
                        </source>
                    </sources>
                    <includes>
                        <include>com.dataprocess.flink.aspect.ClusterEntrypointAspect</include>
                        <include>com.dataprocess.flink.aspect.ReporterSetupAspect</include>
                        <include>com.dataprocess.flink.aspect.FlinkConfigAspect</include>
                        <include>com.dataprocess.flink.aspect.DefaultExecutionPlanStoreAspect</include>
                        <include>com.dataprocess.flink.aspect.FileSystemJobResultStoreAspect</include>
                        <include>com.dataprocess.flink.aspect.ZooKeeperUtilsAspect</include>
                        <include>com.dataprocess.flink.aspect.DefaultCompletedCheckpointStoreUtilsAspect</include>
                    </includes>
                    <weaveDirectories>
                        <weaveDirectory>${project.build.directory}/classes</weaveDirectory>
                    </weaveDirectories>
                    <weaveDependencies>
                        <weaveDependency>
                            <groupId>org.apache.flink</groupId>
                            <artifactId>flink-runtime</artifactId>
                        </weaveDependency>
                    </weaveDependencies>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.aspectj</groupId>
                        <artifactId>aspectjtools</artifactId>
                        <version>${aspectjtools.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>${maven-dependency-plugin.version}</version>
                <executions>
                    <execution>
                        <id>unpack-overridden-class</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.dataprocess</groupId>
                                    <artifactId>dataprocess-flink</artifactId>
                                    <version>${dataprocess.project.version}</version>
                                    <type>jar</type>
                                    <includes>org/apache/flink/**</includes>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${project.build.directory}/classes</outputDirectory>
                            <overWriteReleases>true</overWriteReleases>
                            <overWriteSnapshots>true</overWriteSnapshots>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>${maven-shade-plugin.version}</version>
                <dependencies>
                    <dependency>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-maven-plugin</artifactId>
                        <version>${spring-boot.version}</version>
                    </dependency>
                </dependencies>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                            <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.AppendingTransformer">
                                    <resource>META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports</resource>
                                </transformer>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>com.dataprocess.manager.DataProcessApplication</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
相关推荐
小趴蔡ha4 小时前
02 Anaconda、Python 与机器学习开发环境入门
python·机器学习·anaconda
2401_868534784 小时前
RTOS之RT-Thread & Linux:线程/进程管理与调度核心差异分析
c++·python
jikemaoshiyanshi4 小时前
AWS 中国峰会 2026 有哪些 AI Agent 相关演讲可以看?按业务、研发与生产阶段选看
大数据·人工智能
网易易盾4 小时前
AI互动产品安全合规体系架构:制度/技术/运营/证据四层落地
人工智能·安全·aigc·内容安全
新知图书5 小时前
4.3 链接速读
人工智能·语音识别·ai助手·千问
江苏久众新视5 小时前
SOP-AI实战:基于AI视觉与视频检测,精准管控空调管件装配防漏防错
人工智能
数字化转型分享点滴5 小时前
富士康、蓝思科技为何选择四化信息?MES制造执行系统的实践
python·科技
wling03015 小时前
vasp虚频计算-python脚本
开发语言·windows·python·vasp计算
魔镜前的帅比5 小时前
(开源项目)x-claw(总)
python·ai·rust·开源
xrandzj6 小时前
Python面向对象编程入门:类、实例、初始化与封装实践
开发语言·python