我是WS新手我正在尝试在Eclipse IDE中学习和创建RESTful WS。我已经从Youtube学习了几个教程。我无法找到任何建立你的环境。在谷歌我跟随不同的帖子,了解了如何设置我的环境。但是,我仍未能成功部署项目。
请原谅这个愚蠢的问题,但我无法弄清楚如何解决这个问题。
我正在使用Jersey 1.17.1库和Tomcat 7服务器。我的部署失败了。请帮忙
以下是我项目的工件: 我的班级:
>>> my_list = ['Reten\xc3\xa7\xc3\xa3o (RET)', 'blah blah ...']
>>> my_string = 'Retenção (RET)'
>>> my_list[0].decode('utf-8')
u'Reten\xe7\xe3o (RET)'
>>> my_string.decode('utf-8')
u'Reten\xe7\xe3o (RET)'
我的Web.xml文件:
package com.service.user;
import javax.ws.rs.*
@Path("/user/service")
public class UserServices {
@PUT
@Path("/create")
public void creatUser()
{}
@GET
public void getUser()
{
System.out.print("Inside the getUser Method");
}
@POST
public void updateUser()
{
System.out.print("Inside the Update user Method");
}
@DELETE
public void deleteUser()
{}
}
在尝试解决错误的过程中,我遇到了一些帖子,说我需要Maven。已将我的项目转换为Maven项目,下面是我的pom.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" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>RESTfulWebService1</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Jersey</servlet-name>
<servlet-class>com.sun.jersey.spi.container.servlet.servletContainer</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Jersey</servlet-name>
<url-pattern>/backend/*</url-pattern>
</servlet-mapping>
</web-app>
我在尝试部署项目时收到此错误。
以下是从Eclipse控制台剪切的
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>RESTfulWebService1</groupId>
<artifactId>RESTfulWebService1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>asm</groupId>
<artifactId>asm</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-bundle</artifactId>
<version>1.17.1</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.17.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-core</artifactId>
<version>1.17.1</version>
</dependency>
</dependencies>
</project>
我尝试了几次清洁和重建,但没有运气。