To recreate, put the following in a file, say bug.groovy
@RestController
class Bug {
@RequestMapping("*")
String home() {
new groovy.json.JsonSlurper()
"!"
}
}
Run it:
spring run bug.groovy
startup failed:
file:/Users/curt.cox/tmp/spring-boot/bug.groovy: 6: unable to resolve class groovy.json.JsonSlurper
@ line 6, column 6.
new groovy.json.JsonSlurper()
^
1 error
When writing groovy scripts, all of the standard groovy classes should be available. If you delete the line creating JsonSlurper, the application runs as expected.
JSONSlurper is in groovy-json which isn't on the classpath by default. If you want to use it, you can use @Grab:
@Grab("org.codehaus.groovy:groovy-json")
@RestController
class Works {
@RequestMapping("*")
String home() {
new groovy.json.JsonSlurper()
"!"
}
}
There's no need for a version as Spring Boot's dependency management will take care of that for you.
Most helpful comment
JSONSlurper is in groovy-json which isn't on the classpath by default. If you want to use it, you can use
@Grab:There's no need for a version as Spring Boot's dependency management will take care of that for you.