这里的想法是从数据库加载一些 xml 来使用,但我需要它是一个在启动时加载一次的 bean。 xml 绝对必须位于数据库中。
如果这是重复的,我深表歉意,但我找不到任何详细说明此问题的信息。
最佳答案
除非在范围
中另外指定,否则默认情况下所有 Spring bean 都是singleton
。因此,当您的应用程序部署时,它将在此时加载。
<!-- bean that uses the loaded XML configs from the db -->
<bean id="someDAO" class="myPackage.SomeDAO">
<property name="configLoader">
<ref local="configLoader"/>
</property>
</bean>
<!-- bean that loads the XML data from the database -->
<bean id="configLoader" class="myPackage.ConfigLoader" />
关于java - 我可以从数据库中的 blob 加载 Spring contextConfigLocation 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5820154/