Micronaut-@Endpoint ID中的配置占位符会忽略自定义值

时间:2019-10-18 23:06:52

标签: micronaut

我正在这样定义端点:

@Endpoint(id = '${jupyter.endpoint.path:jupyter/kernel}')
public class KernelEndpoint {

    @Write
    public Map start (request) {
        return [
            "message": "Kernel start request received!"
        ]
    }

}

当我运行应用程序时未传递jupyter.endpoint.path的任何值时,端点id已正确设置为默认值jupyter/kernel

但是,如果我这样输入自定义值:

def endpointPath = "command/jupyter/start-kernel"
def serverUrl = "https://localhost:8080"
// create application context
ApplicationContext applicationContext = ApplicationContext.run([
    'jupyter.endpoint.path': endpointPath,
    'jupyter.server-url': serverUrl
], Environment.TEST)

端点id将忽略自定义值,并仍使用默认值:

 assert applicationContext
    .getBeanDefinition(KernelEndpoint)
    .getAnnotation(Endpoint)
    .stringValue("id")
    .get() == endpointPath

我在文档中找不到任何指示一种或另一种方式是否可行的文档。有谁知道我的尝试是否应该起作用,如果可以,为什么不适合我?

0 个答案:

没有答案