错误:意外错误:非法名称 .$HelloControllerDefinition [英] error: Unexpected error: Illegal name .$HelloControllerDefinition

查看:89
本文介绍了错误:意外错误:非法名称 .$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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆