IntelliJ 无法为 org.gradle.api.Project 类型的根项目“Blue Bot”设置未知属性“mainClassName”

Jon*_*nes 1 gradle

我正在按照教程制作一个基本的 Discord Bot,(https://medium.com/discord-bots/making-a-basic-discord-bot-with-java-834949008c2b)我得到了错误,无法设置org.gradle.api.Project 类型的根项目“Blue Bot”的未知属性“mainClassName”,我不知道如何修复它。这是我的build.grade代码

plugins {
    id 'java'
}
mainClassName = "Main"
group 'BlueBot'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
    jcenter()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile 'net.dv8tion:JDA:4.0.0_62'
}
Run Code Online (Sandbox Code Playgroud)

这是我的Main.java代码

import net.dv8tion.jda.api.AccountType;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;

import javax.security.auth.login.LoginException;


public class Main extends ListenerAdapter {
    public static void main(String[] args) throws LoginException {
        JDABuilder builder = new JDABuilder(AccountType.BOT);
        String token = "enter token here";
        builder.setToken(token);
        builder.addEventListeners(new Main());
        builder.build();
    }

    @Override
    public void onMessageReceived(MessageReceivedEvent event) {
        System.out.println("We received a message from " +
                event.getAuthor().getName() + ": " +
                event.getMessage().getContentDisplay()
        );

        if (event.getMessage().getContentRaw().equals("I am lonely")) {
            event.getChannel().sendMessage("Who isn't?").queue();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

如果您需要更多信息,请告诉我。

Min*_*inn 5

您需要应用应用程序插件:

plugins {
    id 'application'
}
Run Code Online (Sandbox Code Playgroud)