我試圖實例從Java科特林類,但每一次我嘗試使用Maven編譯我的錯誤cannot find symbol
:錯誤試圖從Java
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
}
}
不知道爲什麼沒」 t格式,但無論如何,在我將它轉換爲Kotlin類之前,我需要在我的主類(它是一個Java類)中註冊該命令。當我試圖從一個Java類實例化一個科特林類有在IDE中沒有錯誤,但是當我去編譯Maven的尖叫
cannot find symbol
[ERROR] symbol: class ConfigCommand
你能否提供一些更多的上下文和編譯文件的代碼?也許甚至提供一個最小的失敗例子? –
@ChristianBrüggemann這樣做有幫助還是需要更多? –
你是否在你的'pom.xml'中配置了Kotlin Maven插件[詳見這裏](https://kotlinlang.org/docs/reference/using-maven.html)?如果是,你的'pom.xml'看起來像什麼? 順便說一句,在StackOverflow上的代碼格式是使用4空格縮進完成的。 –