A message body writer for Java class not found

前端 未结 6 856
花落未央
花落未央 2020-12-01 04:46

I am new to using JAX-RS and wrote a sample application that outputs a json object. but I am getting an exception. Here is my code:

@Path(\"/hello\")
public          


        
6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-01 05:37

    Just a small addition. In case if you do not use the web.xml descriptor file, you may enable the POJOMappingFeatire programatically as shown below

    ...
    final ResourceConfig rc = new PackagesResourceConfig("com.test.resources");
        final Map config = new HashMap();
        config.put("com.sun.jersey.api.json.POJOMappingFeature", true);
        rc.setPropertiesAndFeatures(config);
    ...
    

提交回复
热议问题