错误:意外错误:非法名称 .$HelloControllerDefinition [英] error: Unexpected error: Illegal name .$HelloControllerDefinition
问题描述
我遵循了入门指南.应用程序的第一次启动是好的.然后我按照描述添加了一个控制器(src/main/java/helloworld 中的HelloController.java.当我重新启动服务器时,出现以下错误:
c:\dev\micronaut\helloworld>gradlew 运行
<块引用>
任务:编译Java失败注意:为 1 个类型元素创建 bean 类错误:意外错误:非法名称 .$HelloControllerDefinition1 个错误
我在 Windows 10 下使用 jdk 1.8_171
正如 Graeme Rocher 提到的,该类缺少它的 package
.如果您添加我在下面添加的行,它应该可以工作.
打包helloworld;导入 io.micronaut.http.annotation.*;@Controller("/你好")公共类 HelloController {@得到公共字符串索引(){返回你好世界";}}
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
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";
}
}
这篇关于错误:意外错误:非法名称 .$HelloControllerDefinition的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!