Recently webservice, I use it jdk Self contained wsimport Tool to generate client code , The generated code was found to have compilation errors , The error is described below :

The method getPort(QName, Class<T>) in the type Service is not applicable for the arguments (QName, Class<SCServicePortType>, WebServiceFeature[]).

I created a new project to test the generated client code without such an error , So the reason for the mistake is that jar Package conflict .....

Nearly twists and turns , Finally let me find out , original This class , It exists in jdk Self contained rt.jar in , It also exists in my project reference package jaxws-api.jar, There are two such cases jar There is a problem that the package name and class name are identical in the package . What I need is rt.jar Medium class , But it's automatically introduced jaxws-api.jar Of class , But these two jar The bag can't be removed .

therefore , Only change the compiler preference jar order ( This order can be changed ): stay Eclipse It's in Java Build Path-》Order and Export inside , adopt "up"/"down" The buttons change the order , hold jaxws-api.jar Put in jdk It's OK below .