小编alt*_*vic的帖子

OpenApi java.time.Duration 默认格式

我正在使用 springdoc 生成我的 OpenAPI 文档。

public class MyDto {
    ....
    @JsonFormat(shape = JsonFormat.Shape.STRING)
    private Duration duration;
    ....
}
Run Code Online (Sandbox Code Playgroud)

OpenApi 显示的定义MyDto如下,持续时间被反序列化为类似以下内容:

"duration": {
    "seconds": 0,
    "nano": 0,
    "negative": true,
    "zero": true,
    "units": [
      {
        "dateBased": true,
        "timeBased": true,
        "duration": {
          "seconds": 0,
          "nano": 0,
          "negative": true,
          "zero": true
        },
        "durationEstimated": true
      }
    ]
  }
Run Code Online (Sandbox Code Playgroud)

我希望将其格式化为字符串,而不必添加@Schema(type = "string", format = "duration")到每个字段java.util.Duration的所有 DTO 中Duration

jackson-datatype-jsr310的类路径和序列化/反序列化负载按预期使用ISO 8601格式的字符串工作,除了 OpenAPI 显示错误的格式。

是否有可能以某种方式告诉 OpenAPIjava.util.Duration …

java openapi springdoc

7
推荐指数
1
解决办法
229
查看次数

仅当 bean 作为方法参数存在时 Spring 自动装配

我用来@ConditionalOnProperty创建一个FileCompressorbean:

@Bean
@ConditionalOnProperty(prefix = "file.rollover.sink", name = "compress", matchIfMissing = true)
public FileCompressor fileCompressor() {
    return new DefaultFileCompressor(...);
}
Run Code Online (Sandbox Code Playgroud)

我想FileCompressor仅在 bean 存在时(null如果file.rollover.sink.compress=false作为方法参数)自动装配 bean。但如果我尝试将其定义为:

@Bean
public RolloverTask rolloverTask(final IntervalCalculator intervalCalculator, final @Autowired(required = false) FileCompressor fileCompressor) {
    return new RolloverTask(intervalCalculator, fileCompressor);
}
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

Parameter 1 of method rolloverTask in com.example.FileRolloverSinkConfiguration required a bean of type 'com.example.compressor.FileCompressor' that could not be found.
    - Bean method 'fileCompressor' in 'FileRolloverSinkConfiguration' not loaded because @ConditionalOnProperty …
Run Code Online (Sandbox Code Playgroud)

java spring spring-boot

5
推荐指数
1
解决办法
7249
查看次数

使用 application.yaml 启动 ktor

我正在尝试使用 启动 ktor application.yaml

如果我尝试使用如下所示的嵌入式服务器启动它,它会按预期开始侦听为嵌入式服务器定义的端口。

fun main() {
    embeddedServer(Netty, port = 8080, host = "localhost", module = Application::main)
        .start(wait = true)
}

fun Application.main() {
    install(Koin) {
        slf4jLogger()
        modules(myModule)
    }
    configureRouting()
}
Run Code Online (Sandbox Code Playgroud)

但如果我将我的更改main为:

fun main(args: Array<String>): Unit = EngineMain.main(args)
Run Code Online (Sandbox Code Playgroud)

我希望 ktor 从以下位置读取端口src/resources/application.yaml

ktor:
  deployment:
    host: "localhost"
    port: 8080
  application:
    modules:
      - com.example.ApplicationKt.main
Run Code Online (Sandbox Code Playgroud)

相反,我收到此错误:

Neither port nor sslPort specified. Use command line options -port/-sslPort or configure connectors in application.conf
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

kotlin ktor

3
推荐指数
1
解决办法
502
查看次数

Lua 表作为 redis 参数

我正在尝试MSETNX从 Lua 脚本调用 redis。如果它们不存在,我需要设置一些带有空值的键。

我试着这样做:

redis.call('MSETNX', KEYS)KEYS{'key1', '', 'key2', ''}传递给脚本。

但这不起作用,因为此调用需要作为参数传递的单个键和值,而不是表。

这有效:

redis.call('MSETNX', 'key1', '', 'key2', '')

但是 KEYS 变量是动态的,所以我不能那样做。

如何MSETNX在不必单独明确列出每个键的情况下调用?

- 编辑 -

是否可以unpack“混合”值?

我可以通过KEYS = {'key1', 'key2'}unpack它:'key1', '', 'key2', ''?谢谢!

lua redis lua-table

2
推荐指数
1
解决办法
947
查看次数

IntelliJ IDEA 2017.3无法创建新的maven模块?

我刚刚将IntelliJ IDEA更新到2017.3但我似乎无法插入新的Maven模块?当我尝试插入它时根本没有任何事情发生.我打开了idea.txt日志,发现了这个:

2017-12-01 11:25:28,464 [ 551502]  ERROR - llij.ide.plugins.PluginManager - IntelliJ IDEA 2017.3  Build #IU-173.3727.127 
2017-12-01 11:25:28,464 [ 551502]  ERROR - llij.ide.plugins.PluginManager - JDK: 1.8.0_152-release 
2017-12-01 11:25:28,464 [ 551502]  ERROR - llij.ide.plugins.PluginManager - VM: OpenJDK 64-Bit Server VM 
2017-12-01 11:25:28,464 [ 551502]  ERROR - llij.ide.plugins.PluginManager - Vendor: JetBrains s.r.o 
2017-12-01 11:25:28,464 [ 551502]  ERROR - llij.ide.plugins.PluginManager - OS: Windows 10 
2017-12-01 11:25:28,464 [ 551502]  ERROR - llij.ide.plugins.PluginManager - Last Action: NewModuleInGroup 
2017-12-01 11:25:38,059 [ 561097]   INFO - ide.actions.ShowFilePathAction - 
Exit …
Run Code Online (Sandbox Code Playgroud)

intellij-idea

2
推荐指数
1
解决办法
338
查看次数

标签 统计

java ×2

intellij-idea ×1

kotlin ×1

ktor ×1

lua ×1

lua-table ×1

openapi ×1

redis ×1

spring ×1

spring-boot ×1

springdoc ×1