【发布时间】:2017-10-05 16:07:24
【问题描述】:
我正在尝试从 Java 实例化 Kotlin 类,但每次尝试使用 Maven 编译时都会收到错误 cannot find symbol:
class ConfigCommand(private val game: Game) : Command("config", "") {
init {
addAliases("cfg")
}
override fun getRequiredRank(): Rank? {
return null
}
override fun getDescription(): String {
return "Shows the config for the game"
}
@Throws(CommandException::class)
override fun execute(sender: CommandSender, args: Array<String>): Boolean {
if (args.isEmpty()) {
if (sender !is Player)
throw NoConsoleAccessException()
sender.openInventory(ConfigGUI(game).build())
return true
}
return false
}
}
不知道为什么格式不正确,但无论如何在我将它转换为 Kotlin 类之前它可以工作,但我需要在我的主类中注册这个命令,这是一个 Java 类。当我尝试从 Java 类实例化 Kotlin 类时,IDE 中没有错误,但是当我去编译它时,maven 尖叫
cannot find symbol
[ERROR] symbol: class ConfigCommand
【问题讨论】:
-
您能否提供更多上下文和要编译的文件代码?也许甚至提供一个最小的失败示例?
-
@ChristianBrüggemann 这有帮助还是您需要更多?
-
您是否将
pom.xml中的Kotlin Maven 插件配置为described here?如果是,您的pom.xml是什么样的?顺便说一句,StackOverflow 上的代码格式化是使用 4 个空格缩进完成的。 -
@ChristianBrüggemann 我有,here 是我的 pom.xml
-
你的 pom 缺少 @ChristianBrüggemann 告诉你的链接中显示的
sourceDirs声明......再次在这里:kotlinlang.org/docs/reference/…