I have two maven projects,
testmvn:
<groupId>com.avs</groupId>
<artifactId>testmvn</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>testmvn</name>
mvnusedemo:
<groupId>com.avs</groupId>
<artifactId>mvnusedemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>mvnusedemo</name>
now I have a class in project testmvn
package com.avs.Calculation;
public class AddNumbersME {
public int addNumbers(int a, int b) {
return a + b;
}
public int addNumbers(int a, int b, int c) {
return a + b + c;
}
}
i have run mvn install cmd, I got Build Success. In the local repo(.m2) I can see those jars
Now I am trying to use this class(AddNumbersME) in project mvnusedemo
<dependency>
<groupId>com.avs</groupId>
<artifactId>testmvn</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
Now I can see the dependency added to the maven dependency folder in eclipse.
public static void main(String[] args) {
SpringApplication.run(MvnusedemoApplication.class, args);
AddNumbersME a = new AddNumbersME(); // getting error - could not resolve
}
error: AddNumbersME cannot be resolved to a typeJava
need help, do I am missing something ??
one of my friends helped me out, need to provide executions inside build -> plugin in pom.xml it looks like
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
<configuration>
<classifier>exec</classifier>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
now it is working fine.
You have the same group id in two of the projects. So use only import Calculation.AddNumbersME Don't add com.avs! Another suggestion: don't use uppercase package names such as Calculation. Use lower case calculation as the package name!
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.