CloudOptions 配置参考
CloudOptions 是 Feat Cloud 服务的核心配置类,继承自 ServerOptions,除本文档列出的特有配置外,还支持端口、线程池、SSL 等基础配置。
packages
Section titled “packages”指定启动时扫描的包路径,用于限制组件扫描范围。
| 属性 | 值 |
|---|---|
| 类型 | String[] |
| 默认值 | null(扫描所有包) |
FeatCloud.cloudServer(options -> { options.setPackages("com.example.controller", "com.example.service");}).listen();registerBean
Section titled “registerBean”向容器注册外部 Bean 实例,注册后可通过 @Autowired 注入使用。
| 属性 | 值 |
|---|---|
| 方法签名 | CloudOptions registerBean(String key, Object value) |
| 返回值 | CloudOptions(支持链式调用) |
FeatCloud.cloudServer(options -> { options.registerBean("dataSource", createDataSource()); options.registerBean("redisTemplate", createRedisTemplate());}).listen();staticLocations
Section titled “staticLocations”指定静态资源文件的存放位置。
| 属性 | 值 |
|---|---|
| 类型 | String |
| 默认值 | "classpath:static" |
支持三种路径格式:
// 类路径(默认)options.setStaticLocations("classpath:static");
// 自定义类路径options.setStaticLocations("classpath:assets");
// 文件系统路径options.setStaticLocations("file:/var/www/static");public class Application { public static void main(String[] args) { FeatCloud.cloudServer(options -> { // 限制扫描范围 options.setPackages("com.example");
// 注册外部 Bean options.registerBean("dataSource", DataSourceBuilder.create() .url("jdbc:mysql://localhost:3306/test") .username("root") .password("password") .build());
// 静态资源路径 options.setStaticLocations("classpath:public"); }).listen(); }}CloudOptions 继承自 ServerOptions,支持端口、线程数、缓冲区、安全等配置,详见 ServerOptions 配置参考。
- 快速开始 - CloudOptions 入门使用
- 控制器开发 - 使用注册 Bean 开发控制器
- ServerOptions 配置参考 - 继承的基础配置项