util:constant 引入java类中的常量
实践一下
package cn.zno.ztest; public class SomeBean { private int i; public int getI() { return i; } public void setI(int i) { this.i = i; } @Override public String toString() { return "SomeBean [i=" + i + "]"; } }
spring bean configuration :
<bean id="someBean" class="cn.zno.ztest.SomeBean"> <property name="i"> <util:constant static-field="java.sql.Connection.TRANSACTION_SERIALIZABLE"/> </property> </bean>
测试:
public static void main(String[] args) { String[] xmls = new String[] { "classpath*:spring/root/public_*.xml", "classpath:spring/root/private_*.xml" }; ApplicationContext ac = new ClassPathXmlApplicationContext(xmls); SomeBean bean = (SomeBean)ac.getBean("someBean"); System.out.println(bean); }
结果:
SomeBean [i=8]
应用场景
外层引用内层的静态常量
(JDK依赖 .... 三方依赖 .... 基础包 ... web应用)
( 内层 ---------------------> 外层)