Spring Boot groovy编译错误:意外的令牌@ @第45行

时间:2015-07-14 21:03:33

标签: groovy annotations spring-boot

我正在尝试将Spring Boot项目中的Java控制器转换为Groovy,并在尝试编译和运行时遇到最奇怪的错误

unexpected token: @ @ line 45, column 5
@RequestMapping(value = {"/v1/foo", "/foo"}, method = GET)
^

这令我感到困惑。注释是Java或Groovy中的注释,对吧?我错过了什么?这是我的代码的抽象

// src/main/groovy/my/package/FooController.groovy, formerly .java

/// ... proper imports

@RestController
@EnableAutoConfiguration
public class FooController {

    // ... @autowire services

    @RequestMapping(value = {"/v1/foo", "/foo"}, method = GET)
    public ResponseEntity get(@RequestHeader HttpHeaders headers) {
      // do work return ResponseEntity
    }

    @RequestMapping(value = {"/v1/foo", "/foo"}, method = PUT)
    public ResponseEntity put(@RequestHeader HttpHeaders headers, @ResponseBody @Valid final MyFoo myFoo) {
      // do work return ResponseEntity
    }
}

0 个答案:

没有答案