error: Unexpected error: Illegal name .$HelloControllerDefinition

纵然是瞬间 提交于 2020-01-06 13:58:29

问题


I have followed the Getting Started. First start of Application was Ok. Then I added a Controller as described (HelloController.java in src/main/java/helloworld. When I restart the server, I get the following error:

c:\dev\micronaut\helloworld>gradlew run

Task :compileJava FAILED Note: Creating bean classes for 1 type elements error: Unexpected error: Illegal name .$HelloControllerDefinition 1 error

I am under Windows 10 with jdk 1.8_171


回答1:


As Graeme Rocher mentioned, the class is missing it's package. If you add the line I've added below, it should work.

package helloworld;

import io.micronaut.http.annotation.*;

@Controller("/hello")
public class HelloController {
    @Get
    public String index() {
        return "Hello World";
    }
}


来源:https://stackoverflow.com/questions/51057886/error-unexpected-error-illegal-name-hellocontrollerdefinition

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!