问题描述
我有一个控制台应用程序.我想从数据库读取一些配置设置.这些设置应该存储在全局或会话变量中,以便我可以在整个应用程序中使用该变量,我该如何实施?有哪些方法?我需要使用哪些频道?以及应如何存储有效载荷?
i have a console application.i want to read some configuration settings from DB. And these settings should be stored in a global or session variable soi can use the variable through out the application ,how can i implement it ? what are the ways ? which channels do i need to use ? and how payload should be stored?
推荐答案
你的意思完全不清楚,但是你可以将 Map 对象声明为 @Bean
(或 <bean/>
) 并在初始化期间加载它.
It's not at all clear what you mean, but you can declare a Map object as a @Bean
(or <bean/>
) and load it up during initialization.
然后,您可以通过 @Autowired
或通过 SpEL 在集成组件中的表达式中直接在组件中引用它:@mapBean['foo']
.
You can then reference it directly in your components by @Autowired
or via SpEL in expressions in integration components: @mapBean['foo']
.
这篇关于如何声明和使用全局变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!