kotlin - @Controller 的元注释在 Micronaut 中不起作用
问题描述
我正在尝试实现@Controller
如下的自定义注释(元注释):
@MustBeDocumented
@Retention(AnnotationRetention.RUNTIME)
@Target(AnnotationTarget.CLASS)
@Secured(SecurityRule.IS_AUTHENTICATED)
@Controller
annotation class CustomController(
@get:AliasFor(annotation = Controller::class)
val value: String
)
//Usage:
@CustomController("/demo-api")
class ChangeController(private val changeGroupApi: ChangeGroupApi) {
//...
}
但是,Micronaut 的行为就好像控制器类根本没有注释一样。见相关日志,类未注解时同理。
相关日志:
10:56:47.351 [default-nioEventLoopGroup-1-2] DEBUG i.m.s.rules.InterceptUrlMapRule - One or more of the IP patterns matched the host address [127.0.0.1]. Continuing request processing.
10:56:47.352 [default-nioEventLoopGroup-1-2] DEBUG i.m.s.rules.InterceptUrlMapRule - No url map pattern exact match found for path [/demo-api] and method [GET]. Searching in patterns with no defined method.
10:56:47.352 [default-nioEventLoopGroup-1-2] DEBUG i.m.s.rules.InterceptUrlMapRule - No url map pattern match found for path [/demo-api]. Returning unknown.
10:56:47.352 [default-nioEventLoopGroup-1-2] DEBUG i.m.security.filters.SecurityFilter - Authorized request GET /demo-api. No rule provider authorized or rejected the request.
有什么想法让它发挥作用吗?
解决方案
推荐阅读
- sql-server - 带输入文件的 BCP
- google-apps-script - 可安装触发器在 Apps 脚本中停止工作
- java - Selenium 脚本在弹出窗口打开时挂起并在 10 分钟后正常运行
- reactjs - React-native ComponentDidMount 未触发
- laravel - composer require 可以找到包
- ios - 使用 XIB 的导航栏中的文本字段
- javascript - 画布不会正确附加
- angular6 - 如何在 Angular 7 中动态更改模态文本
- foreach - SwiftUI 在 ScrollView 中自动滚动到底部(底部优先)
- c# - 基于相关表中的值的要求,ExpressiveAnnotations