Maven '的泛型类型参数;地图';在弗林克CEP失踪

Maven '的泛型类型参数;地图';在弗林克CEP失踪,maven,apache-flink,eclipse-jdt,flink-streaming,flink-cep,Maven,Apache Flink,Eclipse Jdt,Flink Streaming,Flink Cep,Flink CEP中检测模式的代码如下所示 // Generate temperature warnings for each matched warning pattern DataStream<TemperatureEvent> warnings = tempPatternStream.select( (Map<String, MonitoringEvent> pattern) -> { TemperatureEvent first =

Flink CEP中检测模式的代码如下所示

// Generate temperature warnings for each matched warning pattern

DataStream<TemperatureEvent> warnings = tempPatternStream.select(
    (Map<String, MonitoringEvent> pattern) -> {
        TemperatureEvent first = (TemperatureEvent) pattern.get("first");


        return new TemperatureEvent(first.getRackID(), first.getTemperature()) ;
    }
);
但是,构建usign
mvn clean install
,然后通过Control+R运行显示输出

  • 我想知道为什么这种情况一直在发生

  • 有办法吗

PS:不过我使用的是EclipseJDT插件,即使它在日志中显示错误。POM.XML的内容如下

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <compilerId>jdt</compilerId>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.eclipse.tycho</groupId>
                        <artifactId>tycho-compiler-jdt</artifactId>
                        <version>0.21.0</version>
                    </dependency>
                </dependencies>
            </plugin>

org.apache.maven.plugins
maven编译器插件
3.1
1.8
1.8
jdt
org.eclipse.tycho
第谷编译器jdt
0.21.0

欢迎您提出建议。请提前感谢

首先,检查您的
jdk
版本,是
1.8
?并将
tycho compiler jdt
的版本升级到
1.0.0
您的san参考以下插件:

<plugin>
    <!-- Use compiler plugin with tycho as the adapter to the JDT compiler. -->
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
        <compilerId>jdt</compilerId>
    </configuration>
    <dependencies>
        <!-- This dependency provides the implementation of compiler "jdt": -->
        <dependency>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-compiler-jdt</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>
</plugin>


在此之后,您必须使用maven在cli上构建项目。一旦程序通过maven构建,您也可以在IntelliJ中运行它。

我知道Java 8 Lambda非常方便。但是,它们几乎不通过反射提供类型信息,这就是为什么Flink在生成底层序列化程序时遇到问题的原因。为了在IDE中运行Flink程序,我建议在涉及泛型类型时使用Java匿名类而不是lambdas。

感谢您的回复。将版本更新到1.0.0对我不起作用,是的,我安装了JDK 1.8。请尝试删除
.m2
目录,重建并更新项目并尝试运行,这可能会解决您的问题。不幸的是,我也面临同样的问题,问题是,您需要使用EclipseJDT编译器构建项目,并且由于您可能正在使用IntelliJ或Eclipse以外的其他IDE,因此每次修改代码时都需要使用maven进行构建,否则将使用默认编译器删除类型信息。目前,每次使用maven构建是唯一的解决方案(AFAIK)
<plugin>
    <!-- Use compiler plugin with tycho as the adapter to the JDT compiler. -->
    <artifactId>maven-compiler-plugin</artifactId>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
        <compilerId>jdt</compilerId>
    </configuration>
    <dependencies>
        <!-- This dependency provides the implementation of compiler "jdt": -->
        <dependency>
            <groupId>org.eclipse.tycho</groupId>
            <artifactId>tycho-compiler-jdt</artifactId>
            <version>1.0.0</version>
        </dependency>
    </dependencies>
</plugin>