在 Eclipse 上无法解析导入 javax.ws

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/31587300/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 11:17:09  来源:igfitidea点击:

The import javax.ws cannot be resolved on Eclipse

javaeclipseweb-servicesresttomcat

提问by José María Valbae

I am developing a RESTful's Webservice on java using Eclipsewith the next steps:

我正在使用 Eclipse 在 Java 上开发RESTful 的 Web 服务,并执行以下步骤:

File>New>Dynamic Web Project

文件>新建>动态Web项目

Then I configured these options:

然后我配置了这些选项:

Target runtime: Apache Tomcat v7.0;

Dynamic web module version: 2.5 (because I am using Axis2);

Configuration: Default Configuration for Apache Tomcat v7.0 and (both options)

目标运行时:Apache Tomcat v7.0;

动态网页模块版本:2.5(因为我用的是Axis2);

配置:Apache Tomcat v7.0 和(两个选项)的默认配置

In label "Modify" I added "Axis2 Web Services" and "JAX-RS (REST Web Services)"

在标签“修改”中,我添加了“Axis2 Web 服务”和“JAX-RS(REST Web 服务)”

Next, when I created my new class, I added

接下来,当我创建我的新类时,我添加了

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

导入 javax.ws.rs.GET;
导入 javax.ws.rs.Path;
导入 javax.ws.rs.PathParam;
导入 javax.ws.rs.Produces;
导入 javax.ws.rs.core.MediaType;

but Eclipse launches the notice

但是 Eclipse 会启动通知

The import javax.ws cannot be resolved

导入 javax.ws 无法解析

I don't know the next question

我不知道下一个问题

  • Is it necessary to add all the files .jar to the path WebContent/WEB-INF/lib ?
  • Or you can create, for example, a new path WebContent/WEB-INF/lib-RESTproyect?
  • If I choose the second option, will I have a problem in the future with my project?
  • 是否有必要将所有文件 .jar 添加到路径 WebContent/WEB-INF/lib ?
  • 或者您可以创建,例如,一个新路径 WebContent/WEB-INF/lib-RESTproyect?
  • 如果我选择第二个选项,我以后的项目会不会有问题?

回答by sumeet kumar

Import the jar file: javax.ws.rs-api-2.0.jar And add it to java build path. The issue will be resolved in windows.

导入jar文件:javax.ws.rs-api-2.0.jar并添加到java构建路径。该问题将在 windows 中解决。

回答by MonsieurBeilto

Import the jar file: javax.ws.rs-api-2.0.jar And add it to java build path. The issue will be resolved in windows.

导入jar文件:javax.ws.rs-api-2.0.jar并添加到java构建路径。该问题将在 windows 中解决。

Link to the jar : http://www.java2s.com/Code/Jar/j/Downloadjavaxwsrsapi20jar.htm

jar 链接:http: //www.java2s.com/Code/Jar/j/Downloadjavaxwsrsapi20jar.htm

Information on importing it to Eclipse : http://tech.amikelive.com/node-269/eclipse-quick-tip-resolving-error-the-import-javaxservlet-cannot-be-resolved/comment-page-1/

有关将其导入 Eclipse 的信息:http: //tech.amikelive.com/node-269/eclipse-quick-tip-resolving-error-the-import-javaxservlet-cannot-be-resolved/comment-page-1/