- spring在项目初始化时加载类
public class InitDataListener implements InitializingBean, ServletContextAware {
<!-- spring系统启动以后,加载该类,查询所有数据 -->
<bean class="com.zfsoft.listener.init.InitDataListener" />
2.spring加载远程配置文件
<?xml version="1.0" encoding="UTF-8"?>
2 <beans xmlns="http://www.springframework.org/schema/beans"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 xmlns:p="http://www.springframework.org/schema/p"
5 xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
6
7 <bean id="propertyPlaceholderConfigurer"
8 class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
9
10 <!-- during developing, you can uncomment this to load local properties -->
11 <!-- <property name="location" value="application.properties"/> -->
12
13 <property name="properties">
14 <bean id="remoteProperties" class="org.demo.RemoteProperties"
15 p:url="http://172.21.12*.**/config/dev/application.properties"/>
16 </property>
17 </bean>
18
19 <bean class="org.demo.Foo" p:name="${name}"></bean>
20
21 </beans>
来自博客http://www.cnblogs.com/yjmyzz/p/how-to-load-remote-config-in-spring.html
本文介绍如何在Spring项目中实现初始化数据加载及远程配置文件的读取。通过实现InitializingBean接口和ServletContextAware接口,可以在项目启动时加载数据。此外,还介绍了如何使用PropertyPlaceholderConfigurer来加载远程HTTP配置文件。
18万+

被折叠的 条评论
为什么被折叠?



