简体   繁体   English

如何从属性文件中指定的XML文件加载Spring bean定义?

[英]How do I load Spring bean definitions from XML file specified in a properties file?

I specified name of XML file with Spring bean definitions in a properties file: 我在属性文件中用Spring bean定义指定了XML文件的名称:

myConfigurationFile=mySpringConfigurationFile1.xml myConfigurationFile = mySpringConfigurationFile1.xml

How do I tell Spring to load those bean definitions into Spring context defined by JavaConfig? 如何告诉Spring将这些bean定义加载到JavaConfig定义的Spring上下文中? It seems that I need an equivalent of @ImportResource, called programmatically from JavaConfig. 似乎我需要一个等效的@ImportResource,可以从JavaConfig中以编程方式调用。 How do I do that? 我怎么做?

Hi you can use FileSystemXmlApplicationContext or ClassPathXmlApplicationContext to achieve this. 嗨,您可以使用FileSystemXmlApplicationContext或ClassPathXmlApplicationContext实现此目的。

https://docs.spring.io/spring/docs/3.0.0.M4/reference/html/ch04s07.html https://docs.spring.io/spring/docs/3.0.0.M4/reference/html/ch04s07.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Spring 找不到 bean xml 配置文件:“无法从相对位置导入 bean 定义” - Spring cannot find bean xml configuration file: “Failed to import bean definitions from relative location” Spring MVC-以编程方式从appContext.xml加载bean定义 - Spring MVC - Load bean definitions from appContext.xml programatically 从spring中的环境变量中指定的路径加载属性文件 - Load a properties file from a path specified in environment variable in spring 使用Spring从XML属性文件加载并注入属性Bean - Load and Inject to Property Bean from XML Property File with Spring 如何从XML属性文件加载变量? - How can I load variables from an XML properties file? 如何使用Spring将嵌套键值对从属性文件加载到Java对象中? - How do I load nested key value pairs from a properties file into a Java object using Spring? Spring Bean属性文件 - Spring Bean Properties file 如何使用spring从属性文件中加载地图 - how to load map from properties file with spring 如何使用.properties文件中的值初始化spring bean中的集合 - How to initialize a set in a spring bean using value from .properties file 即使从路径中的文件,也无法从URL位置[classpath:spring / spring-persistence-layer.xml]导入bean定义 - Failed to import bean definitions from URL location [classpath:spring/spring-persistence-layer.xml] even when the file in the path
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM