Exception in thread “main” java.lang.NoClassDefFoundError: Could not initialize class com.sun.jersey.core.header.MediaTypes

后端 未结 3 638
陌清茗
陌清茗 2021-01-02 12:39

I\'m trying to run a jersey client and facing this issue.

WS Class:

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
im         


        
3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-02 13:23

    For followers, these (with mockito in this instance, but kind of generic):

    java.lang.NoClassDefFoundError: com/sun/jersey/spi/inject/Errors$Closure
    
    java.lang.NoClassDefFoundError: com/sun/jersey/core/header/LinkHeaders
    

    meant "you have a dependency on jersey-core 1.0.2 and also dependency on jersey-client 1.11" (need to match core with client versions more closely). Unfortunately "server" and "client" both use the "core" so in the end they practically all have to precisely match up :|

提交回复
热议问题