如何从命令行运行Kotlin的spark java

我对Java很陌生(大概7年没有这样做)。 我正在使用Gradle,使用spark-java创建一个简单的Hello World应用程序,它只是运行这个:

import static spark.Spark.*; fun main(args: Array<String>) { get("/hello", (req, res) -> "Hello World!"); } 

在Eclipse中,我可以通过获取gradle插件并启动一个新的gradle项目来实现。 但也有“科林”项目。 所以你不能用kotlin启动一个新的gradle项目。

我想说的是,通过JavaScript和Node,我通常都是通过命令行完成所有的事情。 我想建立这个项目,并从命令行运行服务器与Gradle,但我不知道如何做到这一点。

这是我目前的build.gradle:

 // Apply the kotlin plugin to add support for Kotlin apply plugin: 'kotlin' buildscript { ext.kotlin_version = '1.1.2-4' repositories { jcenter() mavenCentral() } sourceSets { main.kotlin.srcDirs += 'src/main/myKotlin' main.java.srcDirs += 'src/main/myJava' } dependencies { classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.1.2-4' } } // In this section you declare where to find the dependencies of your project repositories { // Use 'jcenter' for resolving your dependencies. // You can declare any Maven/Ivy/file repository here. jcenter() } // In this section you declare the dependencies for your production and test code dependencies { // The production code uses the SLF4J logging API at compile time compile 'com.sparkjava:spark-core:2.3' // Declare the dependency for your favourite test framework you want to use in your tests. // TestNG is also supported by the Gradle Test task. Just change the // testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add // 'test.useTestNG()' to your build script. testCompile 'junit:junit:4.12' } 

我在命令行上运行gradle ,它成功建立,但我将如何启动服务器,所以我可以去localhost:4567 ,看到我的Hello World输出? 什么是我应该遵循的一般流程?

要清楚:我正在做一个良心的决定,使用Kotlin而不是Java。