如何解决无法向 SpringFactoriesLoader 加载的 spring 模块添加属性
我有一个 springboot 项目,它引导一个从其他 jar 加载 springfactories 的过程。
@SpringBootApplication
public class MyApp{
/**
* The entry point of application.
*
* @param args the input arguments
*/
public static void main(String[] args) throws InterruptedException {
final ConfigurableApplicationContext run = SpringApplication.run(MyApp.class,args);
new FnContext((AnnotationConfigReactiveWebServerApplicationContext) run).bootstrap();
}
}
MyApp 项目有自己的 application.yaml 文件加载一些配置
FnContext 引导方法:
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
// The SpringFactoriesLoader search for function declarations in external jars spring.factories files
final List<MyFunction> functionService= SpringFactoriesLoader.loadFactories(Function.class,null);
function.forEach(k -> {
// and register functionto load additional spring configuration into the context
context.register(k.getClass());
LOG.info("function{}",k);
});
// The context is then joined to the Spring Boot run context to get Shared configuration.
context.setParent(runcontext);
// A refresh is necessary to apply registered beans
context.refresh();
问题是当我在 SpringFactoriesLoader 加载的模块之一中添加属性文件时,所有属性都被忽略,它们仅从父属性文件(来自 MyApp 项目的 properties.yaml)中获取属性
>有什么建议吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。