Ste*_*anS 2 java google-app-engine jersey
在SpringSource Tool Suite中,我创建了一个标准的谷歌应用引擎项目.我添加了Jersey以支持REST.开发服务器启动正常,但是当我尝试获取URL(例如http:// localhost:8888/sibibjersey/api)时,我只是得到了404.我想这是一个简单的配置问题,但解决方案似乎躲避我......
这里是主要文件:
web.xml看起来像这样.
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<init-param>
<param-name>com.sun.jersey.config.feature.DisableWADL</param-name>
<param-value>true</param-value>
</init-param>
<servlet>
<servlet-name>Jersey Web Application</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>com.sun.jersey.config.property.packages</param-name>
<param-value>com.sibib.main</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey Web Application</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Run Code Online (Sandbox Code Playgroud)
我尝试了像/*和/ rest/*这样的url-pattern的变体,但似乎都没有.
com.sibib.main中唯一的Java类是InfoResource.java:
package com.sibib.main;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
@Path("/api")
public class InfoResource {
@GET
public String info() {
return "Hello Jersey on Google App Engine";
}
}
Run Code Online (Sandbox Code Playgroud)
我尝试将@Path添加到info函数中,但没有效果.当我启动服务器并导航到例如http:// localhost:8888/sibibjersey/api时,我只是得到一个404.加载http:// localhost:8888加载war.html文件夹中的index.html.
这些是项目中引用的lib:
任何提示都非常感谢!
谢谢!
您可以尝试从上下文路径中删除sibibjersey,只需尝试使用http:// localhost:8888/api在我的本地,我还没有看到Google App Engine的应用程序有项目路径以及http:// localhost:8888我跟着http: //tugdualgrall.blogspot.com/2010/02/create-and-deploy-jax-rs-rest-service.html它对我没有任何问题.
归档时间: |
|
查看次数: |
2662 次 |
最近记录: |