Reputation: 423
I have two projects. ABC and XYZ . What I need is to get the ABC classes in XYZ
.For this I have added dependency of ABC into XYZ and did the mvn clean in eclipse. It worked!
but when I did mvn clean install it is showing
Failed to execute goal on project XYZ: Could not resolve dependencies
Failure to find ABC-SERVER:ABC:jar:Server in https://repo.maven.apache.org/maven2 was cached in the local repository.
Here is my pom's ABC's pom.xml:
<groupId>abc-server</groupId>
<artifactId>ABCServer</artifactId>
<name>ABCServer</name>
<version>Server</version>
<packaging>war</packaging>
XYZ's pom.xml:
<dependency>
<groupId>abc-server</groupId>
<artifactId>ABCServer</artifactId>
<version>Server</version>
</dependency>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgument>-Xlint:all</compilerArgument>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
</plugins>
What is the way to do this. I need to run mvn clean package from windows command line.
Any help would be highly appreciated.
Upvotes: 0
Views: 376
Reputation: 165
Look at the error message:
Failure to find ABC-SERVER:ABC:jar:Server
Obviously, it will never find that dependency because no such artifact exists. Your ABC-SERVER is packaged as a war.
You can make it resolve the dependency correctly by adding <type>war</type>
to the dependency in XYZ, but if XYZ is also a war, this may not be what you want. Maven will overlay the ABC-SERVER war on the XYZ war (see https://maven.apache.org/plugins/maven-war-plugin/overlays.html for more details).
If you just want to reuse the classes from the ABC-SERVER webapp, I suppose the correct way to do that is to separate the classes into a new jar artifact and use that in both webapps.
Upvotes: 1
Reputation: 5871
The problem is that you are packaging the project ABC as war. you need to change the packaging to jar..
So change <packaging>war</packaging>
to <packaging>jar</packaging>
Upvotes: 0
Reputation: 858
you have to deploy your ABCServer artifact to your remote repository.
a mvn deploy
on your ABCServer repository should do the trick
Upvotes: 0