1

Using eclipse maven and java 1.7 I have designed two backends named webservice.staff.backend and webservice.webuser.backend .

Now There is another webservice which is written by some of our Senior Team Member, which is a another module for Project shared with me by git.

In this New Project in pom.xml there are two local project dependency have been added as Follows.

    <dependency>
        <groupId>webservice.staff.backend</groupId>
        <artifactId>webservice.staff.backend</artifactId>
        <version>1.0.0</version>
        <classifier>classes</classifier>
        <type>jar</type>   //used jar but webservices packaging as a war
    </dependency>
    <dependency>
        <groupId>webservice.webuser.backend</groupId>
        <artifactId>webservice.webuser.backend</artifactId>
        <version>1.0.0</version>
        <classifier>classes</classifier>
        <type>jar</type> // used jar but webservices packaging as a war
    </dependency>

but these dependency is not resolved when I am just trying to perform Maven clean install. What I Found in my earlier webservice Projects are packaging as a WAR but here used as jar

Here is earlier Project packaging type in pom.xml.

<groupId>webservice.staff.backend</groupId>
    <artifactId>webservice.staff.backend</artifactId>
    <packaging>war</packaging> //packaged as war but used as jar??

<groupId>webservice.webuser.backend</groupId>
    <artifactId>webservice.webuser.backend</artifactId>
    <packaging>war</packaging>  //packaged as war but used as jar in

    /*I Have also Changed packaging as a jar and then clean Install 
      and try to build the New Project but error still the same. */

Error StackTrace

[ERROR] Failed to execute goal on project webservice.credit.backend: Could not resolve dependencies for project webservice.credit.backend:webservice.credit.backend:war:2.0.0: The following artifacts could not be resolved: webservice.staff.webservice.staff.backend:jar:classes:1.0.0, webservice.webuser.backend:webservice.webuser.backend:jar:classes:1.0.0: Failure to find webservice.staff.backend:webservice.staff.backend:jar:classes:1.0.0 in http://download.java.net/maven/2/ was cached in the local repository, resolution will not be reattempted until the update interval of Java.Net has elapsed or updates are forced -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.

Note :- I have tried so many ways and also so many answers on stackOverflowin this regard but no one gives me correct solution to that.

Please Help anybody to Resolve this.. Thanks.

Vikrant Kashyap
  • 6,398
  • 3
  • 32
  • 52
  • follow all steps and check if you are getting any issue after that : http://www.avajava.com/tutorials/lessons/how-do-i-add-a-project-as-a-dependency-of-another-project.html?page=1 – Dipali Vasani Mar 15 '16 at 06:24
  • http://stackoverflow.com/questions/31020038/how-can-i-add-war-file-to-another-java-web-application-dependencies , this one can help too – Dipali Vasani Mar 15 '16 at 06:29
  • Thanks but I have tried this too at earlier @DipaliVasani – Vikrant Kashyap Mar 15 '16 at 06:29
  • as you may see version 2.0.0 is for Investor backend not for `staff` and `web-User` backend actually . Dependency is added with `1.0.0` for `staff` and `web-user` – Vikrant Kashyap Mar 15 '16 at 06:33
  • check your settings.xml for ${user.home}/.m2/repository – Dipali Vasani Mar 15 '16 at 06:38
  • @DipaliVasani.. Please Read the question again.. I thing u didn't get my Context. bydway I have already checked my `.m2` Directory and ` jar `and `war` both is Present. Thanks – Vikrant Kashyap Mar 15 '16 at 06:45

2 Answers2

0

Finally !!!
Got the solution for this.

what i need to do during clean & install add extra param with mvn to export the class files. parameter ==> -Dattach.and.archive.classes=true to the mvn command.

mvn clean install -Dattach.and.archive.classes=true //added one extra param
   // -Dattach.and.archive.classes=true solved my dependency Problem.

Note :- If you Defined in pom.xml Project packaging as war and want a jar as dependency in Your local maven Repository. Just put this extra Option with -Dattach.and.archive.classes=true with mvn.

Vikrant Kashyap
  • 6,398
  • 3
  • 32
  • 52
0

Remove <classifier>classes</classifier>

<dependency>
    <groupId>webservice.staff.backend</groupId>
    <artifactId>webservice.staff.backend</artifactId>
    <version>1.0.0</version>
    <type>jar</type>
</dependency>
<dependency>
    <groupId>webservice.webuser.backend</groupId>
    <artifactId>webservice.webuser.backend</artifactId>
    <version>1.0.0</version>
    <type>jar</type>
</dependency>

pom will be same for both projects except packaging will be jar :

<groupId>webservice.staff.backend</groupId>
<artifactId>webservice.staff.backend</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>

<groupId>webservice.webuser.backend</groupId>
<artifactId>webservice.webuser.backend</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>

Make sure your settings.xml is like below :

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
                      https://maven.apache.org/xsd/settings-1.0.0.xsd">
  <localRepository>${user.home}/.m2/repository</localRepository>
  <interactiveMode>true</interactiveMode>
  ------
</settings>

I have uploaded sample here.

Dipali Vasani
  • 2,526
  • 2
  • 16
  • 30
  • I got the solution and I mentioned my solution here. I Have no time to do a R&D so, I will check out your solution as soon as i will have a free time .. Thanks.. Again For your effort.. :) – Vikrant Kashyap Mar 15 '16 at 08:55
  • I am not using `setting.xml` File Actually.. but thanks Again.. For Your Effort. – Vikrant Kashyap Mar 15 '16 at 08:57