gpt4 book ai didi

Micronaut HelloWorld 错误 : Unexpected error: Illegal name . $HelloControllerDefinition

转载 作者:行者123 更新时间:2023-12-05 00:11:55 32 4
gpt4 key购买 nike

尝试在 上继续演示代码https://docs.micronaut.io/latest/guide/index.html#creatingServer

步骤如下:
src/main/java/example/helloworld/HelloController.java

出现错误:

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

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 7s
1 actionable task: 1 executed


我知道还有另一个问题与此相关但没有答案
error: Unexpected error: Illegal name .$HelloControllerDefinition

我该怎么办?

和 hellocontroller 完全按照文档说明如下

import io.micronaut.http.annotation.*;

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

最佳答案

HelloController需要定义在一个包中。如果您完全按照指南进行操作,请尝试以下操作,

package example.helloworld;

import io.micronaut.http.annotation.*;

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

关于Micronaut HelloWorld 错误 : Unexpected error: Illegal name . $HelloControllerDefinition,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52092243/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com