eclipse 为什么我的导入不被识别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11677673/
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
Why my imports are not recognized
提问by Bohn
Using EClipse, First: I created a Dynamic Web Project and copied soem JAR files ( Jersey Jar files ) to WebContent\WEB-INF\lib folder of that project.
使用 EClipse,首先:我创建了一个动态 Web 项目并将 soem JAR 文件(Jersey Jar 文件)复制到该项目的 WebContent\WEB-INF\lib 文件夹中。
Then I created a new class and on top of it I used some imports such as these:
然后我创建了一个新类,在它之上我使用了一些导入,例如:
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
but it shows some red X errors next to all of them saying the import cannot be resolved.
但它在所有这些错误旁边都显示了一些红色 X 错误,表示无法解析导入。
That's ALL I have done. Is there any other settings I should do to fix these errors?
这就是我所做的一切。我应该做任何其他设置来修复这些错误吗?
回答by pisomojado
Additional information for Jersey newbies: Those imports come from javax.ws.rs-api-2.0.jar, which is found in the "api" directory in the Jersey download, not in the "lib" directory with the jersey-*.jar jars.
Jersey 新手的附加信息:这些导入来自 javax.ws.rs-api-2.0.jar,它位于 Jersey 下载的“api”目录中,而不是在带有 jersey-*.jar 的“lib”目录中罐子。
回答by Robert
First, make sure you ran "refresh" on the project. If that doesn't pick up the JARs then navigate to them in Eclipse's Project Explorer, right-click on them and in the popup menu use "Build Path" > "Add to Build Path".
首先,确保您对项目运行了“刷新”。如果没有找到 JAR,则在 Eclipse 的项目资源管理器中导航到它们,右键单击它们并在弹出菜单中使用“构建路径”>“添加到构建路径”。