问题描述
我正在开发 Quarkus 应用程序,我想要做的是从 application.properties 文件中为所有其余休息设置全局路径,我的应用程序正在工作,但在调用休息请求时,它给出了未找到 404。
@ApplicationScoped
public class ABC {
@POST
@javax.ws.rs.Path("/callit")
public Uni<Response> deleteNoti()
{
//whatever logic
}
}
@ApplicationScoped
public class PAR {
@POST
@javax.ws.rs.Path("/callitPar")
public Uni<Response> addNoti()
{
//whatever logic
}
}
在 application.properties 文件中,我正在配置以下属性:
quarkus.resteasy.path=/rest/*
quarkus.rest.path=/rest/*
quarkus.http.root-path=/myapp
但是当我从前端调用休息请求时它不起作用,我的休息请求应该如下:
http://localhost:8080/myapp/rest/callit
http://localhost:8080/myapp/rest/callitPar
我想要的是每个 rest 请求都应该以“/rest/*”开头,我的应用程序基 URL 应该是“/myapp”,让我知道我们如何实现它?
解决方法
尝试使用 @Path("/")
注释您的资源类并设置 quarkus.resteasy.path=/rest
。
这应该会导致您描述的行为。
quarkus.rest.path
可以删除。