由于缺少mainClass,因此无法在Visual Studio中调试Flink示例

Aviral Srivastava:

我的目的是调试该代码,以按照教程中的建议进行实时查看

我的IDE是Visual Studio Code,此示例的语言是Java。我正在运行Flink Datastream API教程。

当我在任一行上设置断点时,出现以下错误:

Cannot find a class with the main method in the folder 'frauddetection'.

我被提示要创建launch.json文件,因此,这就是我创建的:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "java",
            "name": "Debug (Launch) - Current File",
            "request": "launch",
            "mainClass": "FraudDetectionJob"
        }
    ]
}

即使配置了上面的文件并指定了mainClass,在调试器终端中我仍然遇到相同的错误:

Error: Could not find or load main class FraudDetectionJob

我尝试执行的代码如下:

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package spendreport;

import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.walkthrough.common.sink.AlertSink;
import org.apache.flink.walkthrough.common.entity.Alert;
import org.apache.flink.walkthrough.common.entity.Transaction;
import org.apache.flink.walkthrough.common.source.TransactionSource;

/**
 * Skeleton code for the datastream walkthrough
 */
public class FraudDetectionJob {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        DataStream<Transaction> transactions = env
            .addSource(new TransactionSource())
            .name("transactions");

        DataStream<Alert> alerts = transactions
            .keyBy(Transaction::getAccountId)
            .process(new FraudDetector())
            .name("fraud-detector");

        alerts
            .addSink(new AlertSink())
            .name("send-alerts");

        env.execute("Fraud Detection");
    }
}

如何调试此文件?

Shubham Arora:

我相信您无法编译和运行该应用程序。在您的中pom.xml,这是导致问题的原因

<dependency>
    <groupId>org.apache.flink</groupId>
    <artifactId>flink-streaming-java_${scala.binary.version}</artifactId>
    <version>${flink.version}</version>
    <scope>provided</scope>
</dependency>

更改范围以compile解决此问题。另外,请在此处获取更多技术信息

-我如何找到问题的-

我尝试在教程中(在Intellij IDEA中)运行示例,并得到与您类似的错误:

Error: Unable to initialize main class spendreport.FraudDetectionJob
Caused by: java.lang.NoClassDefFoundError: org/apache/flink/streaming/api/functions/source/SourceFunction

在进一步搜索中,我发现了类似的答案

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Visual Studio 2013无法在CSHTML中调试JavaScript

无法在Visual Studio代码中调试Go

无法在Visual Studio 2013中禁用Javascript调试?

由于缺少proguard-rules.txt,因此无法在Android Studio中生成已签名的APK

无法在Visual Studio 2013中使用断点调试测试

调试时无法在Visual Studio中编写代码

无法在Visual Studio代码中启动C ++调试器

由于未找到节点,因此无法模拟酶中的新闻

由于Kryonet中重复的类定义,因此无法编译项目

由于缺少Content-Type,因此无法解码JSON

由于缺少有效身份中的角色,因此无法生成用于访问数据集的嵌入令牌

由于无法显示设计,因此无法在android studio中实例化一个或多个类错误

无法在Visual Studio Code中调试Django单元测试

Kotlin调试无法在Visual Studio代码中启动

由于无法在macOS Catalina中验证开发人员,因此无法打开翻转器

由于无法在Chrome控制台中进行编程,因此通过Visual Studio Code在我的网站上运行一些javascript代码

由于缺少键盘布局,因此无法登录Windows 7

由于路由器中设置了webfilter,因此无法更新

在LinqPad中调试Visual Studio Linq查询

调试时无法跳过Visual Studio中的代码

由于IIS锁定了程序集,因此无法生成Visual Studio 2013.2

由于缺少zsh,因此无法以root或用户身份登录

由于缺少文件,无法将项目签入Visual Studio Online

Visual Studio Community 2013卸载-由于超时时间已到期,因此返回此操作

在Visual Studio中调试时无法识别的属性'targetframework'

由于链接不断变化,因此无法单击日历中的日期

WebStorm 与 Visual Studio 中的调试

由于缺少属性文件(可能与 IDE 相关),MSBuild 无法构建 Visual Studio 项目

无法在 Visual Studio 代码中调试我的 C++ 代码