kotlin - Kotlin - 应用程序项目模板 - 找不到错误主类
问题描述
我正在使用 IntelliJ IDEA 2021.1(社区版) - 构建 #IC-211.6693.111,构建于 2021 年 4 月 6 日。我创建了一个新的 kotlin 项目 - 项目模板(JVM):应用程序,构建系统:Gradle Kotlin,项目 JDK: 1.8 版本 1.8.0_281。在“scr/main/kotlin”文件夹中,我创建了一个带有简单代码的 kotlin 文件,例如“fun main(){println(“Hi!”)}。当我尝试运行该文件时(构建正常),我收到这个错误:“Could not find or load main class MyAppKt”。我做错了什么?
解决方案
Did you also add your main class to the build.gradle
file?
mainClassName = "projectPackage.MyAppKt"
I assume if you are adding the MyAppKt
file manually it is not added to the build.grale
. But clearly more information about the project would help here. Meanwhile check this post Kotlin - Error: Could not find or load main class _DefaultPackage
推荐阅读
- windows-server-2019 - Server 2019 v1809 StandardEvaluation 无法使用 KMS 客户端设置密钥升级到标准
- google-chrome - Google Apps 脚本我想将组织中的所有用户添加到组
- datatables - 具有多个查询的数据表服务器端处理
- javascript - 如何将数据放入 ayncStorage?
- java - 在 tomcat 8 中,如何在 setenv.bat 中提供文件路径以从 java 类中读取
- sql-server - 跟踪数据库中的更改(更新、插入)
- python - 用python在三角形中找到角度
- angular - 如何以反应形式删除一组字段
- python - python中钟摆运动的数值预测不能正确预测
- azure - 如何从逻辑应用发送群发邮件