我想使用JAVA 8(v45)和tomcat 8(v23)製作一個簡單的基於resteasy的API,但是我沒有看到我的通話導致任何流量或日誌活動。無法使Resteasy與Tomcat 8和Java 8一起工作
我的web.xml文件看起來像這樣
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_3_0.xsd"
version="3.0">
<display-name>Test</display-name>
<description>Test</description>
<servlet>
<servlet-name>resteasy</servlet-name>
<servlet-class>org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>resteasy</servlet-name>
<url-pattern>/restfulservices/*</url-pattern>
</servlet-mapping>
<!-- Auto scan REST service -->
<context-param>
<param-name>resteasy.scan</param-name>
<param-value>true</param-value>
</context-param>
<!-- this should be the same URL pattern as the servlet-mapping property -->
<context-param>
<param-name>resteasy.servlet.mapping.prefix</param-name>
<param-value>/restfulservices</param-value>
</context-param>
<listener>
<listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class>
</listener>
<resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>jdbc/cboxDs</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<!-- Environment entry examples -->
<env-entry>
<env-entry-name>test</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>dev</env-entry-value>
</env-entry>
</web-app>
和我的服務類看起來是這樣的:
package test.request.service;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import org.apache.log4j.Logger;
@Path("/dihService")
public class testService {
private static final Logger LOGGER = Logger.getLogger(testService.class);
@GET
@Path("/hello")
public Response getResponseMessage() {
LOGGER.info(" Entered and param is :");
return Response.status(200).entity(" Entered. Hello world").build();
}
}
我部署後,當我打以下網址:http://localhost:10120/resteasy/restfulservices/dihService/hello
我期待日誌中的某些活動,但我沒有看到任何東西。我已經驗證我的服務器正在端口10120上運行,並且我的日誌正常流動。有任何想法嗎??
謝謝Juned。我嘗試了你的建議,但我仍然沒有看到我的日誌中有任何內容,並且我仍然爲同一個URL獲得404錯誤。 – launchpad123