标签:背景 public ack lookup 获取 java code http enc
其实使用spring BeanDefinitionParseDelegate 进行bean解析时,会获取自己的look-up 标签进行解析 ,所以如何使用look-up 标签呢
package beans.lookUp;
/**
* @author lianzheng
* @date 2019-12-21 23:18
* @service User
*/
public class User{
public void showMe(){
System.out.println("i am user");
}
}
package beans.lookUp;
/**
* @author lianzheng
* @date 2019-12-21 23:18
* @service Teacher
*/
public class Teacher extends User {
public void showMe() {
System.out.println("i am teacher");
}
}
package beans.lookUp;
/**
* @author lianzheng
* @date 2019-12-21 23:19
* @service GetBeanTest
*/
public abstract class GetBeanTest{
public void showMe(){
this.getBean().showMe();
}
public abstract User getBean();
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="getBeanTest" class="beans.lookUp.GetBeanTest">
<lookup-method name="getBean" bean="teacher"/>
<lookup-method name="getBean" bean="student"/>
</bean>
<bean id="teacher" class="beans.lookUp.Teacher"/>
<!-- <bean id="student" class="beans.lookUp.Student"/> -->
</beans>
标签:背景 public ack lookup 获取 java code http enc
原文地址:https://www.cnblogs.com/corx/p/12078707.html