我的REST课程:
@Path("/Root")
public class REST{
@GET
@Path("/test")
@Produces(MediaType.TEXT_PLAIN)
public String testClass() {
return "Jersey Test";
}
.....etc}
我的球衣测试:
public class Test extends JerseyTest {
@Override
protected AppDescriptor configure(){
System.out.println("Here");
return (new WebAppDescriptor.Builder(REST.class.getPackage().getName())
.contextParam("contextConfigLocation", "application-context-prm-test.xml").build());
}
@Override
protected TestContainerFactory getTestContainerFactory() {
return new GrizzlyWebTestContainerFactory();
}
@Test
public void testGet(){
WebResource webResource = client().resource("http://localhost:9998/Root/test");
String actual = webResource.getRequestBuilder().get(String.class);
System.out.println(actual);
}
我似乎总是得到404而我现在已经被困4小时了。我错过了什么?
非常感谢!