简体   繁体   中英

Change Default JSON Provider on WebSphere Application Server

I need to know how to override the default JSON Provider on a WebSphere Application Server Environment (versions 8.0 and 8.5). I need to do that due a to an issue found on Jackson library version 1.6 ( https://github.com/FasterXML/jackson-module-jaxb-annotations/issues/3 ).

If anyone could help would be more than welcome.

I did not quite get whether you want to avoid using Jackson at all or you just want a different version.

In your application you can register the providers you want. For example, to use Jettison you need the following:

import org.apache.wink.providers.jettison.JettisonJAXBProvider;

import javax.ws.rs.core.Application;
import java.util.HashSet;
import java.util.Set;

public class YourApplication extends Application {

    @Override
    public Set<Object> getSingletons() {
        Set<Object> singletons = new HashSet<Object>();
        JettisonJAXBProvider jaxbProvider = new JettisonJAXBProvider();
        singletons.add(jaxbProvider);
        return singletons;
    }
}

If you need different Jackson version, why not just put it into WEB-INF/lib and set web module classloading policy to PARENT_LAST?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM