下面列出了com.fasterxml.jackson.databind.ser.std.DateSerializer#com.fasterxml.jackson.datatype.jsr310.JavaTimeModule 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static void configureObjectMapper(ObjectMapper mapper) {
mapper.registerModule(new JavaTimeModule());
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.setSerializationInclusion(Include.NON_NULL);
mapper.setConfig(mapper.getSerializationConfig().withView(ApiOnly.class));
// add all sub types of CloudAccount
for (var type : REFLECTIONS_SUBTYPE_SCANNER.getSubTypesOf(CloudAccount.class)) {
mapper.registerSubtypes(type);
}
// set injectable value to null
var values = new InjectableValues.Std();
values.addValue("hash", null);
mapper.setInjectableValues(values);
}
@Before
public void setup() {
client = new CrnkClient(getBaseUri().toString());
client.getObjectMapper().registerModule(new JavaTimeModule());
JpaModule module = JpaModule.newClientModule();
client.addModule(module);
MetaModuleConfig config = new MetaModuleConfig();
config.addMetaProvider(new ResourceMetaProvider());
MetaModule clientMetaModule = MetaModule.createServerModule(config);
client.addModule(clientMetaModule);
((MetaLookupImpl) metaModule.getLookup()).initialize();
setNetworkTimeout(client, 10000, TimeUnit.SECONDS);
}
StreamingContextImpl(@NotNull final OkHttpClient client,
@NotNull final String streamingUrl,
@NotNull final String authToken,
final int streamingParallelism,
@NotNull final Logger logger,
@NotNull final Executor executor) {
this.logger = logger;
this.publisher = new StreamingEventPublisher(executor);
this.client = client;
this.mapper = new ObjectMapper();
this.mapper.registerModule(new JavaTimeModule());
this.hasStopped = false;
this.wsClients = new WebSocket[streamingParallelism];
this.requestsHistory = new ArrayList<>(streamingParallelism);
this.wsRequest = new okhttp3.Request.Builder().url(streamingUrl).header("Authorization", authToken).build();
for (int i = 0; i < streamingParallelism; i++) {
final StreamingApiListener streamingCallback = new StreamingApiListener(i + 1);
this.wsClients[i] = this.client.newWebSocket(this.wsRequest, streamingCallback);
this.requestsHistory.add(new HashSet<>());
}
}
public BaseContextImpl(@NotNull final OkHttpClient client,
@NotNull final String url,
@NotNull final String authToken,
@NotNull final Logger logger) {
this.authToken = authToken;
this.finalUrl = Objects.requireNonNull(HttpUrl.parse(url))
.newBuilder()
.addPathSegment(this.getPath())
.build();
this.client = client;
this.logger = logger;
this.mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.registerModule(new JavaTimeModule());
mapper.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS);
}