I have some module in OSGi project.
payment
- payment-api
- payment-impl
in payment-api
I have interface UserService
public interface UserService{
String method1(String p1, int p2);
String method2(String p1);
}
And implementation
public class UserServiceImpl implements UserService{
@Override
public String method1(String p1, int p2){
//code
returnt result;
}
@Override
public String method2(String p1){
//code
returnt result;
}
}
And my module payment-impl
has dependency
<dependency>
<groupId>mydomain</groupId>
<artifactId>payment-api</artifactId>
<version>1.0.0</version>
</dependency>
It work fine. But now, if i tried add new mrthod to UserService
and after override this method in UserServiceImpl
I have error:
public interface UserService{
String method1(String p1, int p2);
String method2(String p1);
String test(int a);
}
and
@Override
public String test(int a) {
return "sdfsdff";
}
java:[94,9] method does not override or implement a method from a supertype
But if I delete @Override
annotation all work fine. I cn not understand why? how can this be?
interface Y{
String method();
}
public class X implemets Y{
@Override
String method(){
return "some string";
}//is error
//------
String method(){
return "some string";
}//is fine
}
And if I not implements this method compiler swears. And by default IDE override methosd with annotation. And another methods which have already been implemented work fine without annotations
The impl
module might be referencing a stale version of the api
module. You might want to rename your version 1.0.0-SNAPSHOT
, clear your local maven repository (typically found in ~/.m2/repository
), and then clean and rebuild the product.
I am uncertain whether suffixing the version with SNAPSHOT
is important here, but it is not a bad practice to do so while the product is in development.
I am also uncertain exactly why you might have hit a stale version of the module. To really dig deep into the problem I would recommend:
mvn install
and cannot just rely on the IDE compilation process, that I'm not sure.
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.