简体   繁体   English

IntelliJ IDEA 11中的模块依赖性

[英]Module dependency in IntelliJ IDEA 11

I have made two modules in IntelliJ; 我在IntelliJ中制作了两个模块。 The first one contains business code (EJBs) and the second contains the presentation (JSF) etc. The presentation layer use some of the entities in the business module. 第一个包含业务代码(EJB),第二个包含表示(JSF)等。表示层使用业务模块中的某些实体。

I have made an EAR artifact and added the WAR and JAR to it. 我制作了EAR工件,并添加了WAR和JAR。

My question is: Is it necassary to add the business module as a dependency of the presentation module because aren't everything in a EAR visible for each other? 我的问题是:是否需要将业务模块添加为表示模块的依赖项,因为EAR中的所有内容都不相互可见? And what is the difference between adding it as a module dependency and creating one EAR artifact where both modules are contained? 在将其添加为模块依赖项并在其中包含两个模块的情况下创建一个EAR工件之间有什么区别?

I think you want the dependency for code-assist and other references. 我认为您需要依赖代码辅助和其他参考。 For instance, and I know this isn't completely on-the-mark, I code with JBoss Seam, where "components" declared in the EJB container can be referenced from the web container (in my case, the Seam "components.xml" file found in WEB-INF). 例如,我知道这还不完全正确,我使用JBoss Seam进行了编码,其中EJB容器中声明的“组件”可以从Web容器中引用(在我的情况下,Seam“ components.xml” “文件可在WEB-INF中找到)。

Now, having visibility is one thing, but the actual dependency is taken care of by the fact that (as you rightly say) you're going to have both EJB (.jar) and Web (.war) artifacts within your .ear. 现在,具有可见性是一回事,但是(如您正确地说)您将在您的.ear中同时拥有EJB(.jar)和Web(.war)工件这一事实可以解决实际的依赖性。

So, you avoid EJB stuff ending up in your Web Module by noting in IDEA that the EJB module should be "Provided" (not "Compile"), as set from the Scope column to the right of the name of the EJB module as seen in Project Structure > Modules > [your web module] > Dependencies. 因此,通过在IDEA中注意EJB模块应该“提供”(而不是“编译”),避免EJB出现在Web模块中,就像在EJB模块名称右侧的“作用域”列中设置的那样在项目结构>模块> [您的Web模块]>依赖关系中。

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

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