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

标签 kotlin dropwizard

我正在尝试启动我的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/

相关文章:

java - 如何突出显示回收器 View 的单行或项目并将突出显示的行滚动到屏幕顶部

functional-programming - Kotlin Either monad:重构构造函数调用以处理CPS

android - 使用 ArrayIndexOutOfBoundsException 将 TextView 文本设置为静态文本崩溃(很少)

android - 协程中的热流和冷流是什么,它们之间的区别是什么?

jersey - 在 Dropwizard 应用程序中将 http 客户端注册到 jersey 环境时无法解析符号ExternalServiceResource

android-studio - IntelliJ/Android Studio 中的 Kotlin 函数 "collapse all"

mysql - hibernate OneToOne 关系中的未知mappedBy

java - 将 Apache Commons HttpClient 日志调整为 Dropwizard

java - 如何使用删除向导处理 JSON 负载?

java - 在 Dropwizard 中公开 Prometheus 指标