尝试在 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 executedRun Code Online (Sandbox Code Playgroud)
我知道还有另一个与此相关的问题,但没有回答 错误:意外错误:非法名称 .$HelloControllerDefinition
我该怎么办?
和 hellocontroller 完全按照文档说明如下
import io.micronaut.http.annotation.*;
@Controller("/hello")
public class HelloController {
@Get
public String index() {
return "Hello World";
}
}Run Code Online (Sandbox Code Playgroud)
HelloController需要定义在一个包中。如果您完全按照指南进行操作,请尝试以下操作,
package example.helloworld;
import io.micronaut.http.annotation.*;
@Controller("/hello")
public class HelloController {
@Get
public String index() {
return "Hello World";
}
}Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
363 次 |
| 最近记录: |