gpt4 book ai didi

kotlin - 运行Java -jar时的Dropwizard Kotlin “Main method is not static in class”

转载 作者:行者123 更新时间:2023-12-04 17:43:15 25 4
gpt4 key购买 nike

我正在尝试启动我的Dropwizard Kotlin应用程序。运行时:

java -jar target/application-1.0.jar server environment.yml

我收到以下错误:
Error: Main method is not static in class, please define the main method as: 
public static void main(String[] args)

最佳答案

确保在应用程序类中的main方法是使用@JvmStatic在伴随对象内部定义的:

class MyClass {    
companion object {
@JvmStatic
fun main(args: Array<String>) {
Application().run(*args)
}
}
}

关于kotlin - 运行Java -jar时的Dropwizard Kotlin “Main method is not static in class”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52123044/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com