groovy
apply plugin: 'java'
apply plugin: 'groovy'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:3.0.8'
compile 'org.springframework.boot:spring-boot-starter-web:2.5.5'
}
groovy
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping("/hello")
class HelloWorldController {
@GetMapping
String sayHello() {
return "Hello, World!"
}
}
groovy
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
@SpringBootApplication
class Application {
static void main(String[] args) {
SpringApplication.run(Application, args)
}
}
shell
gradle build
shell
gradle bootRun