SmartMVC
全部文档
指南
功能
认证授权
示例
参考
  • 简体中文
  • English
  • 日本語
  • Русский
GitHub
全部文档
指南
功能
认证授权
示例
参考
  • 简体中文
  • English
  • 日本語
  • Русский
GitHub
  • 参考手册

    • 配置参考
    • API 速查

配置参考

所有属性以 spring.smart.mvc 为前缀。表格中的默认值来自 core 配置模型,并通过 Starter 的 Spring Boot 配置元数据暴露给 IDE。

exception

属性类型默认值说明
exception.enabledbooleantrue注册 SmartMVC 全局异常处理器
exception.status-modeHTTP_STATUS | ALWAYS_OKHTTP_STATUS使用真实 HTTP 状态,或将错误传输状态统一为 200

response

属性类型默认值说明
response.wrap-enabledbooleantrue包装普通 Controller 返回值
response.wrap-voidbooleantrue包装 void / Void 返回值
response.success-messageStringsuccess自动成功响应的 message
response.long-as-stringbooleantrue将 long / Long 序列化为字符串

ApiResponse、byte[]、Spring Resource、StreamingResponseBody 和 ProblemDetail 不会被自动包装。

date-time

属性类型默认值说明
date-time.request-formatStringyyyy-MM-dd HH:mm:ss日期时间类的请求格式
date-time.response-formatStringyyyy-MM-dd HH:mm:ss日期时间类的 JSON 输出格式
date-time.date-request-formatStringyyyy-MM-ddLocalDate 请求格式
date-time.date-response-formatStringyyyy-MM-ddLocalDate 输出格式
date-time.time-request-formatStringHH:mm:ssLocalTime 请求格式
date-time.time-response-formatStringHH:mm:ssLocalTime 输出格式
date-time.zone-idStringsystem-defaultInstant 类和 Date 转换使用的 IANA 时区
date-time.incomplete-input-policyFILL_MISSING | REJECTFILL_MISSING补全或拒绝不完整日期时间输入

支持的类型包括 LocalDateTime、LocalDate、LocalTime、Instant、OffsetDateTime、ZonedDateTime 和 java.util.Date;后四者输出时应用配置时区。

validation

属性类型默认值说明
validation.enabledbooleantrue允许 SmartMVC 接入并处理 Spring MVC 的参数校验结果;关闭时使用 no-op validator

此开关不会安装 Bean Validation 实现。应用必须显式添加 spring-boot-starter-validation,并由应用管理它的版本;SmartMVC 不会传递校验 Provider。

request-log

属性类型默认值说明
request-log.enabledbooleantrue输出方法、URI、状态码与耗时
request-log.levelTRACE | DEBUG | INFO | WARN | ERRORINFO摘要日志级别

有匹配 Controller 时,logger 类别为该 Controller 类。

auth

属性类型默认值说明
auth.enabledbooleantrue启用 SmartMVC 认证与授权检查;拦截器本身仍会注册
auth.modeGLOBAL | ANNOTATEDANNOTATED全局认证,或只认证 @Auth 接口
auth.check-request-permissionbooleanfalse校验身份中的 METHOD:PATH 权限
auth.authorization-headerStringAuthorization读取凭据的请求头
auth.token-prefixStringBearer从请求头值中移除的前缀
auth.exclude-pathsString[][]完全跳过认证的 Spring MVC 路径模式

@Anonymous 在两种模式下都会跳过认证。exclude-paths 也始终生效;在 ANNOTATED 模式下,被排除路径即使带有 @Auth 也不会进入认证拦截。除此之外,ANNOTATED 只处理带 @Auth 的 Handler。

完整 YAML

spring:
  smart:
    mvc:
      exception:
        enabled: true
        status-mode: HTTP_STATUS
      response:
        wrap-enabled: true
        wrap-void: true
        success-message: success
        long-as-string: true
      date-time:
        request-format: yyyy-MM-dd HH:mm:ss
        response-format: yyyy-MM-dd HH:mm:ss
        date-request-format: yyyy-MM-dd
        date-response-format: yyyy-MM-dd
        time-request-format: HH:mm:ss
        time-response-format: HH:mm:ss
        zone-id: system-default
        incomplete-input-policy: FILL_MISSING
      validation:
        enabled: true
      request-log:
        enabled: true
        level: INFO
      auth:
        enabled: true
        mode: ANNOTATED
        check-request-permission: false
        authorization-header: Authorization
        token-prefix: Bearer
        exclude-paths: []
在 GitHub 上编辑此页
最后更新: 2026/8/7 08:33
上一页
登录鉴权示例
下一页
API 速查