I have a interface like this:
public interface GenericWSEndpoint<T1,T2> {
public void call(String url,String operationName, T1 requestObject, T2 responseObject,long timeout) throws Exception;
}
When I try to define an object with this, it gives
org.apache.maven.BuildFailureException: Compilation failure : incompatible types
Object definition:
private static GenericWSEndpoint<BulkCheckBlockageRequest,BulkCheckBlockageResponse> endpoint=GenericWsEndpointFactory.createSpecificEndpoint(WSTypes.CXF);
And factory code:
public class GenericWsEndpointFactory{
public static <T1,T2> GenericWSEndpoint createSpecificEndpoint(WSTypes type){
switch (type) {
case CXF:
return new CXFWsEndPoint<T1,T2>();
}
return null;
}
}
and the CXFWsEndPoint(no constructors defined specificly):
public class CXFWsEndPoint<T1,T2> implements GenericWSEndpoint<T1, T2>{
.
.
}
I have checked the answers about this problem but they are related with definitions like recursive generics
Any ideas?
EDIT: Exception:
[INFO] Compilation failure ResponseManager\\src\\main\\java\\com\\x\\resman\\util\\WebServiceUtil.java:[57,142] incompatible types; no instance(s) of type variable(s) T1,T2 exist so that com.x.rbm.ws.service.GenericWSEndpoint conforms to com.x.rbm.ws.service.GenericWSEndpoint found : com.x.rbm.ws.service.GenericWSEndpoint required:
com.x.rbm.ws.service.GenericWSEndpointequest,com.x.resman.model.checkblockage.BulkCheckBlockageResponse>
Try with the following code:
public static <T1, T2> GenericWSEndpoint<T1, T2> createSpecificEndpoint() {
instead of
public static <T1, T2> GenericWSEndpoint createSpecificEndpoint() {
Are you specifying the Java source version in your Maven POM file? Currently, by default Maven uses 1.5. You probably need something more recent. What version are you using in our IDE?
The relevant Maven configuration is:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
Hope this helps.
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.