我正在使用Java eBay SDK,并且尝试调用addItem API,添加了eBay maven依赖项和存储库,并编写了一个简单的应用程序来添加新的Item。主要如下图所示
public static void main(String[] args) {
App aai = new App();
try {
ItemType item = aai.buildItem();
FeesType fees;
AddItemCall call = new AddItemCall(aai.apiContext);
call.setItem(item);
call.setAutoSetItemUUID(true);
fees = call.addItem();
} catch (Exception e) {
e.printStackTrace();
}
}
我不断收到无法修复的错误:
[main] INFO com.ebay.sdk.SdkAPIInterfaceServiceLocator - loading wsdl : jar:file:/home/mss/.m2/repository/ebaysdkcore/ebaysdkcore/943/ebaysdkcore-943.jar!/eBaySvc.wsdl
Exception in thread "main" java.lang.NoClassDefFoundError: Could not initialize class com.ebay.sdk.SdkAPIInterfaceServiceLocator
at com.ebay.sdk.ApiCall.executeByApiName(ApiCall.java:594)
at com.ebay.sdk.ApiCall.execute(ApiCall.java:348)
at com.ebay.sdk.call.AddItemCall.addItem(AddItemCall.java:162)
at org.ecommerce_eBay.App.main(App.java:38)
有人对此有任何想法吗? 谢谢!
答案 0 :(得分:0)
我在Java 11中遇到了相同的错误。只需将以下依赖项添加到maven文件中:
<dependency>
<groupId>com.ebay</groupId>
<artifactId>ebaysdkcore</artifactId>
<version>1055</version>
<version>1085</version>
</dependency>
<dependency>
<groupId>com.ebay</groupId>
<artifactId>ebaycalls</artifactId>
<version>1055</version>
<version>1085</version>
</dependency>
<dependency>
<groupId>javax.xml.ws</groupId>
<artifactId>jaxws-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>rt</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.sun.xml.ws</groupId>
<artifactId>jaxws-ri</artifactId>
<version>2.3.2</version>
<type>pom</type>
</dependency>
Java 11不再具有 com.sun.xml.ws 依赖性->因此,我们需要显式添加它们。
希望有帮助!