Forest Forest
💒 首页
  • v1.5.30
  • v1.5.28
  • 🎄 ForestX
🌰 案例
💖 支持
🛫 更新记录
🧢 开发团队
⚒️ 参与贡献
  • MaxKey - 业界领先的身份管理和认证产品 (opens new window)
  • Snowy - 国内首个国密前后端分离快速开发平台 (opens new window)
  • Eoapi - 一个开源、可拓展的 API 工具平台 (opens new window)
  • Gitee (opens new window)
  • Github (opens new window)
💒 首页
  • v1.5.30
  • v1.5.28
  • 🎄 ForestX
🌰 案例
💖 支持
🛫 更新记录
🧢 开发团队
⚒️ 参与贡献
  • MaxKey - 业界领先的身份管理和认证产品 (opens new window)
  • Snowy - 国内首个国密前后端分离快速开发平台 (opens new window)
  • Eoapi - 一个开源、可拓展的 API 工具平台 (opens new window)
  • Gitee (opens new window)
  • Github (opens new window)
  • 序言

    • 🎁 新手介绍
    • 📖 文档
    • 🌰 使用案例
    • 🕵️‍ 关于作者
    • 👨‍🎓 贡献者列表
  • 入门

    • 🎬 安装配置说明
    • 🏹 Springboot环境安装
    • 📐 Springboot环境配置
    • 🎯 Springboot环境使用
    • 🏹 Springboot3环境安装
    • 📐 Springboot3环境配置
    • 🎯 Springboot3环境使用
    • 🏹 Spring环境安装
    • 📐 Spring环境配置
      • 🎯 Spring环境使用
      • 🏹 Solon环境安装
      • 📐 Solon环境配置
      • 🎯 Solon环境使用
      • 🏹 原生Java环境安装
      • 📐 原生Java环境配置
      • 🎯 原生Java环境使用
      • 🧬 编程式接口
    • 配置项

      • 👜 Springboot环境配置项
      • 👝 Spring环境配置项
      • 👜 Solon环境配置项
      • 🎒 原生Java环境配置项
      • 📚 配置优先级/作用域
    • 声明式接口

      • 🧱 构建接口
      • 🍀 请求方法
      • 🚚 请求地址
      • 🎈 URL 参数
      • 🍭 请求头
      • 👔 请求体
      • 🍮 后端框架
      • 🧁 接口注解
      • 📬 接收数据
      • 🍛 数据转换
      • 🍓 成功/失败条件
      • 🍌 重试机制
      • 🥂 重定向
      • 🍔 Gzip解压
      • 🎂 日志管理
      • ⚽ 回调函数
      • 🍟 异步请求
      • 🛡️ HTTPS
      • 🍪 使用Cookie
      • 🛸 使用代理
      • 🍉 上传下载
      • 🚑 异常处理
    • 编程式接口

      • 请求API

        • 🚀 请求对象
        • 🚢 请求属性
        • ✨ 执行请求
        • 🎊 后端框架
        • 🎪 请求类型
        • 🔮 请求地址
        • 🧀 URL 参数
        • 🚅 请求头
        • 🚋 请求体
        • ⚓ 回调函数
        • 🚁 异步请求
        • 🥯 Cookie
        • 🍜 成功/失败条件
        • 🌶️ 重试机制
        • ⛵ 重定向
        • 🛰️ 请求代理
      • 响应API

        • 🌠 响应对象
        • ✒️ 读取数据
        • 🦋 响应状态码
        • 🏥 响应错误处理
        • 🎧 响应头
        • 🥞 Cookie
    • 模板表达式

      • 🍬 Hello World
      • 🍹 配置属性引用
      • 🍖 变量引用
      • 🥃 动态变量绑定
      • 🥗 参数序号引用
      • 🍍 引用对象属性
      • 🥝 调用对象方法
    • 高级特性

      • 🥪 拦截器
      • 🍏 自定义注解
      • 🍇 组合注解
      • 🥑 自定义转换器
    • v1.5.30文档
    • 入门
    公子骏
    2022-07-01
    目录

    📐 Spring环境配置

    # 约定大于配置

    Forest是基于约定大于配置的理念进行设计的,如果您已经添加好了Forest Spring环境相关依赖,只要进行些简单的配置即可使用

    # 配置 XML SCEHEMA

    打开spring的上下文配置文件,在beans开头定义的属性中加入Forest的Schema

    xmlns:forest="http://forest.dtflyx.com/schema/forest"
       ...
    xsi:schemaLocation=" ...
    http://forest.dtflyx.com/schema/forest
    http://forest.dtflyx.com/schema/forest/forest-spring.xsd
    ..."
    
    1
    2
    3
    4
    5
    6

    加入完成后类似如下效果

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:forest="http://forest.dtflyx.com/schema/forest"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans.xsd
           http://forest.dtflyx.com/schema/forest
           http://forest.dtflyx.com/schema/forest/forest-spring.xsd">
        
       ...
    
    </beans>
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12

    # 添加Forest基本配置的定义

    <!-- Forest 全局配置 -->
    <!-- maxConnections 每个路由的最大连接数 -->
    <!-- connectTimeout 连接超时时间,单位为毫秒 -->
    <!-- readTimeout 数据读取超时时间,单位为毫秒 -->
    <forest:configuration
            id="configuration"
            maxConnections="500"
            connectTimeout="10000"
            readTimeout="3000">
       
        <!-- 定义 Forest 客户端接口所在的包名 -->
        <!-- 扫描 base-package 属性定义包,然后会将该包名下符合条件的接口进行动态代理并注入到 Spring 的上下文中 -->
        <forest:scan configuration="configuration" base-package="com.yoursite.client"/>
       
    </forest:configuration>
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15

    # 详细配置

    Forest的详细配置说明,请参见《Spring环境配置项》

    帮助我们改善此文档 (opens new window)
    上次更新: 2023/03/13, 15:28:40
    🏹 Spring环境安装
    🎯 Spring环境使用

    ← 🏹 Spring环境安装 🎯 Spring环境使用→

    Theme by Vdoing | Copyright © 2016-2023 公子骏 | MIT License
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式