调整 JSON 序列化的版本
This commit is contained in:
parent
94ed05d9b8
commit
8c43df4bcb
|
@ -16,6 +16,11 @@
|
||||||
<option name="name" value="OSSEZ Private Snapshots" />
|
<option name="name" value="OSSEZ Private Snapshots" />
|
||||||
<option name="url" value="https://repo.ossez.com/repository/maven-snapshots/" />
|
<option name="url" value="https://repo.ossez.com/repository/maven-snapshots/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven_central" />
|
||||||
|
<option name="name" value="Maven Central" />
|
||||||
|
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||||
|
</remote-repository>
|
||||||
<remote-repository>
|
<remote-repository>
|
||||||
<option name="id" value="central" />
|
<option name="id" value="central" />
|
||||||
<option name="name" value="Central Repository" />
|
<option name="name" value="Central Repository" />
|
||||||
|
|
|
@ -62,11 +62,6 @@
|
||||||
<groupId>org.redisson</groupId>
|
<groupId>org.redisson</groupId>
|
||||||
<artifactId>redisson</artifactId>
|
<artifactId>redisson</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
|
||||||
<artifactId>jackson-dataformat-xml</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bouncycastle</groupId>
|
<groupId>org.bouncycastle</groupId>
|
||||||
<artifactId>bcprov-jdk15on</artifactId>
|
<artifactId>bcprov-jdk15on</artifactId>
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
package com.ossez.discourse.client.service;
|
package com.ossez.discourse.client.service;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.StreamReadFeature;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
import com.ossez.discourse.common.exception.DiscourseError;
|
import com.ossez.discourse.common.exception.DiscourseError;
|
||||||
import com.ossez.discourse.common.exception.DiscourseRuntimeException;
|
import com.ossez.discourse.common.exception.DiscourseRuntimeException;
|
||||||
import com.ossez.discourse.common.model.dto.Post;
|
import com.ossez.discourse.common.model.dto.Post;
|
||||||
|
@ -48,10 +50,10 @@ public class TopicsService extends DiscourseClient {
|
||||||
|
|
||||||
if (response.code() == HttpStatus.SC_OK) {
|
if (response.code() == HttpStatus.SC_OK) {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
objectMapper.registerModule(new JavaTimeModule());
|
||||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
|
objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
|
||||||
discourseTopic = Optional.of(objectMapper.readValue(responseStr, Topic.class));
|
discourseTopic = Optional.of(objectMapper.readValue(responseStr, Topic.class));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.slf4j</groupId>
|
<groupId>org.slf4j</groupId>
|
||||||
<artifactId>jcl-over-slf4j</artifactId>
|
<artifactId>jcl-over-slf4j</artifactId>
|
||||||
<version>1.7.36</version>
|
<version>2.0.16</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
||||||
import com.fasterxml.jackson.databind.annotation.JsonNaming;
|
import com.fasterxml.jackson.databind.annotation.JsonNaming;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
|
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
|
||||||
|
@ -18,7 +19,7 @@ public class Topic {
|
||||||
private String title;
|
private String title;
|
||||||
private String fancyTitle;
|
private String fancyTitle;
|
||||||
private Integer postsCount;
|
private Integer postsCount;
|
||||||
private LocalDate createdAt;
|
private LocalDateTime createdAt;
|
||||||
private Integer views;
|
private Integer views;
|
||||||
private Integer replyCount;
|
private Integer replyCount;
|
||||||
private Integer likeCount;
|
private Integer likeCount;
|
||||||
|
@ -109,11 +110,11 @@ public class Topic {
|
||||||
this.postsCount = postsCount;
|
this.postsCount = postsCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalDate getCreatedAt() {
|
public LocalDateTime getCreatedAt() {
|
||||||
return createdAt;
|
return createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCreatedAt(LocalDate createdAt) {
|
public void setCreatedAt(LocalDateTime createdAt) {
|
||||||
this.createdAt = createdAt;
|
this.createdAt = createdAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
26
pom.xml
26
pom.xml
|
@ -133,11 +133,7 @@
|
||||||
<artifactId>gson</artifactId>
|
<artifactId>gson</artifactId>
|
||||||
<version>2.8.9</version>
|
<version>2.8.9</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
|
||||||
<artifactId>jackson-dataformat-xml</artifactId>
|
|
||||||
<version>2.13.0</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- 测试所用依赖 -->
|
<!-- 测试所用依赖 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -304,16 +300,17 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- JSON -->
|
<!-- JSON -->
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-core</artifactId>
|
|
||||||
<version>2.14.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
<version>2.14.0</version>
|
<version>2.17.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||||
|
<artifactId>jackson-dataformat-xml</artifactId>
|
||||||
|
<version>2.17.2</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
<!-- TEST -->
|
<!-- TEST -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -551,5 +548,12 @@
|
||||||
<!-- </plugin>-->
|
<!-- </plugin>-->
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>maven_central</id>
|
||||||
|
<name>Maven Central</name>
|
||||||
|
<url>https://repo.maven.apache.org/maven2/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
Loading…
Reference in New Issue