简体   繁体   English

java EJB:无法解析导入javax.ejb

[英]java EJB: The import javax.ejb cannot be resolved

I am reading the book Getting Started with WebSphere Application Server Community Edition. 我正在阅读“WebSphere Application Server社区版入门”一书。

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 谢谢

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中,右键单击项目 - > properties - > java build path

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。*类。

请注意,此jar文件在开发中很有用,但您不需要(不应该?)将它与war或ear文件一起部署,因为应用程序服务器容器具有自己的运行时Java EE环境。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM