繁体   English   中英

如何在Intellij Idea中使用Gradle向具有相同级别的模块正确添加依赖项?

[英]How to properly add a dependency to a module that's on the same level using Gradle in Intellij Idea?

我有一个普通的Java EE项目,正在移植到Gradle。 我在Intellij Idea中创建的结构包括以下子项目:

\ee_forum_gradle (Uses ear plugin and deploys both the ejb and web project)
\ee_forum_gradle_ejb
\ee_forum_gradle_web (Uses war plugin and is dependent on the ejb project)

我的问题是该Web项目依赖于ejb项目,每次在Intellij中打开该项目时,都必须在该Web项目中单击对模块ee_forum_gradle_ejb_main的添加依赖项,因为每次gradle运行导入时,此设置都会丢失。

我试图使用gradle将ejb项目导入到Web项目中。 所以我加了

includeFlat 'ee_forum_gradle_ejb'

到Web项目的settings.gradle并

compile project(':ee_forum_gradle_ejb')

到Web项目的build.gradle文件。 如果然后尝试在Wildfly 10服务器上运行它,则会出现以下错误:

"WFLYCTL0412: Required services that are not installed:" => ["jboss.deployment.subunit.\"ee_forum_gradle-1.0-SNAPSHOT.ear\".\"ee_forum_gradle_web-1.0-SNAPSHOT.war\".deploymentCompleteService","jboss.deployment.subunit.\"ee_forum_gradle-1.0-SNAPSHOT.ear\".\"ee_forum_gradle_web-1.0-SNAPSHOT.war\".beanmanager","jboss.persistenceunit.\"ee_forum_gradle-1.0-SNAPSHOT.ear/ee_forum_gradle_web-1.0-SNAPSHOT.war#forum-jpa\""],"WFLYCTL0180: Services with missing/unavailable dependencies" => ["jboss.deployment.subunit.\"ee_forum_gradle-1.0-SNAPSHOT.ear\".\"ee_forum_gradle_ejb-1.0-SNAPSHOT.jar\".component.PostBean.START is missing [jboss.persistenceunit.\"ee_forum_gradle-1.0-SNAPSHOT.ear/ee_forum_gradle_web-1.0-SNAPSHOT.war#forum-jpa\"]","jboss.deployment.unit.\"ee_forum_gradle-1.0-SNAPSHOT.ear\".WeldStartService is missing [jboss.persistenceunit.\"ee_forum_gradle-1.0-SNAPSHOT.ear/ee_forum_gradle_web-1.0-SNAPSHOT.war#forum-jpa\"]","jboss.deployment.subunit.\"ee_forum_gradle-1.0-SNAPSHOT.ear\".\"ee_forum_gradle_web-1.0-SNAPSHOT.war\".batch.environment is missing [jboss.deployment.subunit.\"ee_forum_gradle-1.0-SNAPSHOT.ear\".\"ee_forum_gradle_web-1.0-SNAPSHOT.war\".beanmanager]","jboss.deployment.subunit.\"ee_forum_gradle-1.0-SNAPSHOT.ear\".\"ee_forum_gradle_web-1.0-SNAPSHOT.war\".weld.weldClassIntrospector is missing [jboss.deployment.subunit.\"ee_forum_gradle-1.0-SNAPSHOT.ear\".\"ee_forum_gradle_web-1.0-SNAPSHOT.war\".beanmanager]","jboss.deployment.subunit.\"ee_forum_gradle-1.0-SNAPSHOT.ear\".\"ee_forum_gradle_ejb-1.0-SNAPSHOT.jar\".component.UserBean.START is missing [jboss.persistenceunit.\"ee_forum_gradle-1.0-SNAPSHOT.ear/ee_forum_gradle_web-1.0-SNAPSHOT.war#forum-jpa\"]","jboss.deployment.subunit.\"ee_forum_gradle-1.0-SNAPSHOT.ear\".\"ee_forum_gradle_ejb-1.0-SNAPSHOT.jar\".component.ThreadBean.START is missing [jboss.persistenceunit.\"ee_forum_gradle-1.0-SNAPSHOT.ear/ee_forum_gradle_web-1.0-SNAPSHOT.war#forum-jpa\"]","jboss.deployment.unit.\"ee_forum_gradle-1.0-SNAPSHOT.ear\".deploymentCompleteService is missing [jboss.deployment.subunit.\"ee_forum_gradle-1.0-SNAPSHOT.ear\".\"ee_forum_gradle_web-1.0-SNAPSHOT.war\".deploymentCompleteService]","jboss.deployment.subunit.\"ee_forum_gradle-1.0-SNAPSHOT.ear\".\"ee_forum_gradle_ejb-1.0-SNAPSHOT.jar\".component.BoardBean.START is missing [jboss.persistenceunit.\"ee_forum_gradle-1.0-SNAPSHOT.ear/ee_forum_gradle_web-1.0-SNAPSHOT.war#forum-jpa\"]"]}

非常感谢有关如何使该Gradle项目运行的任何想法。 就像我写的一样,如果我单击“ 添加模块依赖项”,则该项目成功运行,但是每次都必须重复此步骤。

好了,解决方案是使用

include('ee_forum_gradle_ejb')

在Web项目的settings.gradle文件中,然后

providedCompile project(':ee_forum_gradle_ejb')

在Web项目的build.gradle文件中。

我认为仅使用compile而不是provideCompile的问题在于,两次包含了ejb项目,这使服务器有些混乱。

暂无
暂无

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

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