我在我的Spring配置的Web服務應用程序中有兩個簡單的資源類。根一(/報道)正常工作一段時間後,所有的路徑返回404.這是資源類:澤西與春天總是給子資源404
package com.factorlab.ws.reports;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@Component
@Scope("prototype")
@Path("reports")
public class ReportsResource {
@Autowired
private TestItemResource timelineResource;
@Path("testitem")
public TestItemResource getTimelinResource() {
return timelineResource;
}
@GET
@Produces(MediaType.TEXT_PLAIN)
public String getTestText() {
return "Success!\n";
}
}
和子資源是在這裏:
package com.factorlab.ws.reports;
import javax.ws.rs.GET;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
@Component
@Scope("prototype")
public class TestItemResource {
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "Success!\n";
}
}
我部署應用程序在一個稱爲factorlab-ws的webapp中的Jetty。 curl http://localhost:8080/factorlab-ws/reports
會產生成功。但curl http://localhost:8080/factorlab-ws/reports/testitem
給出了404狀態。
此外,我在ReportsResouce中的每個方法中放置斷點。 getTestText()打破罰款,但getTimelineResource()不,暗示它永遠不會進入該方法。
我可能會錯過什麼?
「/」的url-pattern不適用於我;但是,啓用跟蹤https://blogs.oracle.com/sandoz/entry/tracing_in_jersey會很有幫助。 – 2012-06-25 17:51:09