Jackson 的 JavaTimeModule可以很好地进行全局序列化/反序列化java.time
,但其默认日期时间格式是 ISO 标准,例如2018-01-10T10:20:30
LocalDateTime 和2018-01-10T10:20:30+08:00
OffsetDateTime。但我需要设置一个全局本地格式,例如2018-01-10 10:20:30
LocalDateTime 和 OffsetDateTime,没有T
OffsetTime (使用本地默认 OffsetTime)。我怎样才能做到这一点?
注:我知道
@JsonFormat
、@JsonSerialize
和@JsonDeserialize
。这不是全局设置。
ID getId()
其中一个接口是“org.springframework.data.domain.Persistable”,它是一个java接口,具有第3方lib中的方法。
另一个接口是 Kotlin 接口interface IdEntry { val id: String}
。
现在我的业务入口需要实现这两个接口:
data class MyEntry(
override val id: String,
....// more properties
) : IdEntry, Persistable<String>
Run Code Online (Sandbox Code Playgroud)
我使用IntelliJ IDE编码,错误是:
Class 'MyEntry' is not abstract and does not implement abstract member
@Nullable public abstract fun getId(): String!
defined in org.springframework.data.domain.Persistable
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?
我还尝试了下面的代码:(来自这里的想法)
data class MyEntry(
private val id: String,
....// more properties
) : IdEntry, Persistable<String> {
override fun getId() = id
...
}
Run Code Online (Sandbox Code Playgroud)
但这也失败了:
Cannot weaken access …
Run Code Online (Sandbox Code Playgroud) 当我使用 时Mono.thenMany
,Flux 数据丢失,为什么?
@Test
fun thenManyLostFluxDataTest() {
Mono.empty<Int>()
.thenMany<Int> { Flux.fromIterable(listOf(1, 2)) }
.subscribe { println(it) } // why not output item 1, 2
}
Run Code Online (Sandbox Code Playgroud)
如果我更改为使用blockLast()
进行订阅,则测试方法将永远运行。好害怕:
@Test
fun thenManyRunForeverTest() {
Mono.empty<Int>()
.thenMany<Int> { Flux.fromIterable(listOf(1, 2)) }
.blockLast() // why run forever
}
Run Code Online (Sandbox Code Playgroud)
现在我使用另一种方式来完成该thenMany
方法应该做的事情:
// this method output item 1, 2
@Test
fun flatMapIterableTest() {
Mono.empty<Int>()
.then(Mono.just(listOf(1, 2)))
.flatMapIterable { it.asIterable() }
.subscribe { println(it) } // output item 1, 2 correctly
}ed
Run Code Online (Sandbox Code Playgroud)