简体   繁体   English

Maven JAR模块取决于WAR中的类

[英]Maven JAR module depends on classes in WAR

I have an application which is packaged as a .war file. 我有一个打包为.war文件的应用程序。 It has GWT code and a set of web-services. 它具有GWT代码和一组Web服务。

I want to move the web-services code to a separate jar file, so the application can be build without them. 我想将Web服务代码移到一个单独的jar文件中,以便可以在没有它们的情况下构建应用程序。

Services depend on code which is currently packaged into .war file, so in pom.xml for jar file I specify the following dependency: 服务取决于当前打包到.war文件中的代码,因此在jar文件的pom.xml中,我指定了以下依赖关系:

<dependency>
    <groupId>my.group</groupId>
    <artifactId>my-war</artifactId>
    <version>1.0.4</version>
</dependency>

But to package the .war archive I also need to specify a dependency for the jar, like this: 但是,要打包.war归档文件,我还需要为jar指定依赖项,如下所示:

<dependency>
    <groupId>my.group</groupId>
    <artifactId>my-services-jar</artifactId>
    <version>1.0.4</version>
    <scope>test</scope>
</dependency>

Which results in Circular Dependency. 这导致循环依赖。

How do I solve this? 我该如何解决这个问题? Or maybe I should follow a different approach? 还是我应该采用不同的方法? Thanks. 谢谢。

Modularize a little more - introduce say a core jar with the dependencies common between my-war and my-services-jar and then your dependency structure will not have the circular dependency. 进一步模块化-介绍说一个核心jar,它具有my-war和my-services-jar之间常见的依赖关系,然后您的依赖关系结构将不具有循环依赖关系。

my-war
    - core-jar
my-services-jar
    - core-jar

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

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