简体   繁体   中英

Maven JAR module depends on classes in WAR

I have an application which is packaged as a .war file. It has GWT code and a set of web-services.

I want to move the web-services code to a separate jar file, so the application can be build without them.

Services depend on code which is currently packaged into .war file, so in pom.xml for jar file I specify the following dependency:

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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