1

我试图在 IntelliJ Idea 上运行一个芭蕾舞女演员程序。然后,编辑配置出现,它说

Error: Main run kind is selected, but the file does not contain a main function.

我该怎么办 ?我应该在程序参数中选择什么。

源代码:

import ballerina.net.http;
import ballerina.lang.messages;

@http:BasePath {value:"/helloservice"}
service helloService {

    @http:GET {}
    @http:PATH {value:"/hello?name={name}"}
    resource hello (message m, @http:QueryParam {value:"name"} string name) {
        string respStr = "Hello, World " + name + "!\n";

        message responce = {};
        messages:setStringPayload(response, respStr);

        reply response;
    }
    }
4

1 回答 1

3

似乎这里的问题是,您手动创建了主运行配置并尝试使用该配置运行服务。请在配置中选择服务运行类型,如下图所示。

在此处输入图像描述

此外,您不必手动创建运行配置。IntelliJ IDEA 插件可以在您使用如下所示的 gutter 运行图标运行主要功能或服务时自动检测运行类型。

运行没有配置的文件

运行配置会自动创建。

配置已创建

如果你先运行一个 main 然后再运行一个服务,运行配置也会随之自动改变。所以不需要人工干预。

在旁注中,代码似乎有更旧的 Ballerina 语法,我建议使用最新的 Ballerina 语法以避免最新的 IntelliJ IDEA 插件出现任何问题。请参阅Ballerina 示例以获取最新语法。

于 2018-06-19T05:04:41.117 回答