当我访问该页面时,无法收到消息“ hello”。
var tasks = new List<Task>();
for (int i = 0; i < 200; i++)
{
tasks.Add(Task.Run(async () =>
{
while (true)
{
var message = new GetHttpMessage("www.stackoverflow.com")
{
Headers = { {"User-agent","Test-agent-1"} }
};
var req = new Request(message);
var resp = await req.SendAsync();
}
}));
}
await Task.WhenAll(tasks);
和此类
package jaxrs.ressources;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
@Path("greeting")
public class HelloRessource {
@GET
@Path("hello")
@Produces(MediaType.TEXT_PLAIN)
public String sayhello() {
return "Hello from JAX-RS";
}}
URL package jaxrs.utilities;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
@ApplicationPath("/rest")
public class RestActivator extends Application{
}
始终显示“未找到”
有什么解决办法吗?
这是包含pom.xml文件的内容:
http://127.0.0.1:8383/JAXRS_Hello_GL-1.0/rest/greeting/hello
请告诉我是否需要其他说明
答案 0 :(得分:0)
您可以添加初始化程序吗?
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-servlet-initializer</artifactId>
<version>3.1.4.Final</version>
</dependency>
保罗先生的评论中有解决方法,请检查