2
我正在嘗試自定義默認傑克遜提供程序的行爲。我寫了下面的代碼並將其放入war包中,但它不起作用。我正在使用JBoss V7.1.1.Final。覆蓋jboss服務器中的默認傑克遜提供程序
@javax.ws.rs.ext.Provider
@javax.ws.rs.Consumes({MediaType.APPLICATION_JSON, "text/json"})
@javax.ws.rs.Produces({MediaType.APPLICATION_JSON, "text/json"})
public class JacksonConfigurator extends JacksonJsonProvider {
private static final Logger log = Logger.getLogger(JacksonConfigurator.class.getName());
public JacksonConfigurator() {
super();
log.info("Configuring JSON data field mapping to C-style");
ObjectMapper mapper = _mapperConfig.getConfiguredMapper();
if (mapper == null) {
mapper = _mapperConfig.getDefaultMapper();
}
mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
}
}