java EJB:无法解析导入 javax.ejb
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9830401/
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
java EJB: The import javax.ejb cannot be resolved
提问by Eric Francis
I am reading the book Getting Started with WebSphere Application Server Community Edition.
我正在阅读 WebSphere Application Server Community Edition 入门一书。
I created an EJB project with Eclipse EE.
我使用 Eclipse EE 创建了一个 EJB 项目。
import javax.ejb.Local;
Error: The import javax.ejb cannot be resolved
错误:无法解析导入 javax.ejb
I don't know why I cannot import this class.
我不知道为什么我不能导入这个类。
Thanks
谢谢
采纳答案by Daniel
Probably the comments under the question already answered this, but just in case clarification is needed:
可能问题下的评论已经回答了这个问题,但以防万一需要澄清:
1) In Eclipse, right click on the project --> properties --> java build path
1)在Eclipse中,右键单击项目-->属性-->java构建路径
2) Click on add external JAR
2)点击添加外部JAR
3) Add c:\glassfish4\glassfish\lib\javaee.jar (Your directory path to this JAR can of course be different.)
3) 添加 c:\glassfish4\glassfish\lib\javaee.jar (你的这个 JAR 的目录路径当然可以不同。)
--> Ok the dialog, and now Eclipse should be able to see javax.ejb.* classes.
--> 好的对话框,现在 Eclipse 应该可以看到 javax.ejb.* 类了。
回答by Peter
Please note that this jar file is useful in development, but you need not (should not?) deploy it along with your war or ear files, because the application server container has its own runtime Java EE environment.
请注意,这个 jar 文件在开发中很有用,但您不需要(不应该?)将它与您的 war 或 ear 文件一起部署,因为应用程序服务器容器有自己的运行时 Java EE 环境。