问题
GET http://localhost:8080/system/version
GET http://localhost:8080/system/version/
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Get;
@Controller("/system")
public class SystemController {
@Get(uri = "/version/")
public String version() {
return SystemController.class.getPackage().getImplementationVersion();
}
}
leads to
{
"message": "Page Not Found",
"_links": {
"self": {
"href": "/system/version/",
"templated": false
}
}
}
How to fix this?
回答1:
If a controller method like that returns null
, that will result in a 404. I expect that SystemController.class.getPackage().getImplementationVersion()
is evaluating to null
.
来源:https://stackoverflow.com/questions/61939066/micronaut-1-3-5-page-not-found