Các Spring Framework Reference Documentation (2.5.x) đưa ra hai ví dụ về làm thế nào để tải một tập tin bất động sản vào một container đậu, một trước khi phát hành phiên bản 2.5 và là một cách ngắn gọn hơn bằng cách sử dụng <util:properties/>
chức năng đó đã được giới thiệu trong phiên bản 2.5:
Trước khi phiên bản 2.5:
<!-- creates a java.util.Properties instance with values loaded from the supplied location -->
<bean id="jdbcConfiguration" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="location" value="classpath:com/foo/jdbc-production.properties"/>
</bean>
Sau khi phiên bản 2.5:
<!-- creates a java.util.Properties instance with values loaded from the supplied location -->
<util:properties id="jdbcConfiguration" location="classpath:com/foo/jdbc-production.properties"/>
Lưu ý rằng để sử dụng <util:properties/>
, bạn phải khai báo các util
namespace và giản đồ vị trí trong lời mở đầu ở phía trên cùng của tập tin cấu hình XML mùa xuân của bạn:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd">
<!-- <bean/> definitions here -->
</beans>
Nguồn
2010-06-04 15:30:49
Nhìn vào giản đồ và tài liệu trong phụ lục A, rõ ràng là không. – laz