CloudOptions 配置
This content is not available in your language yet.
CloudOptions 配置
Section titled “CloudOptions 配置”CloudOptions 定义了 Feat Cloud 服务的配置信息,它继承自 ServerOptions,因此除了自身特有的配置项外,还可以使用 ServerOptions 中的所有配置项。
CloudOptions 特有配置项
Section titled “CloudOptions 特有配置项”packages
Section titled “packages”类型: String[]
默认值: null
用于指定 Feat Cloud 启动时扫描的包路径,限制组件扫描范围以提升启动性能。
使用示例:
FeatCloud.cloudServer(options -> { options.setPackages("com.example.controller", "com.example.service");});
最佳实践:
- 明确指定包路径可以提高应用启动速度,减少不必要的类扫描
- 在大型项目中,建议按功能模块划分包,并只加载需要的包
registerBean
Section titled “registerBean”类型: Map<String, Object>
默认值: 空Map
定义了 Feat Cloud 启动时加载的外部 Bean 配置,可以通过 registerBean
方法添加外部 Bean。
使用示例:
FeatCloud.cloudServer(options -> { options.registerBean("dataSource", createDataSource()); options.registerBean("redisClient", createRedisClient());});
最佳实践:
- 使用有意义的键名,便于在应用中引用
- 注意避免Bean名称冲突,否则会抛出异常