我做了一个 grails 3 应用程序
$ grails create-app helloworld
在这个中,我创建了一个弹簧控制器 DemoController.groovy
package helloworld
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
/**
* A controller responding to
* curl http://localhost:8080/demo
* source location: src/main/groovy/helloworld/DemoController.groovy
*
*/
@RestController
class DemoController {
@RequestMapping("/demo")
String demo() {
"Hello demo!"
}
}
使用
$spring run src/main/groovy/helloworld/DemoController.groovy &
$curl http://localhost:8080/demo
工作正常
使用
$gradle bootrun &
$curl http://localhost:8080/demo
失败!/demo
找不到 的 Grails 报告
当我从一个干净的弹簧启动应用程序(由http://start.spring.io/制作)做同样的事情时,它工作正常
我看不出有什么问题