本人菜鸟。一点不懂Spring,请大侠看看这个spring怎么有错??还有怎么测试啊?书上没有完整的源码。
接口:
package test;
public interface GeLi {
void responseAsk(String s);
}
刘德华类:
package test;
public class LiDeHua implements GeLi {
public void responseAsk(String s) {
System.out.println(s);
}}
墨攻类:
package test;
public class MoAttack {
private GeLi geli;
public void setGeli(GeLi geli){
this.geli=geli;
}
public void cityGateAsk(){
geli.responseAsk("墨者革离");
}
}
那个XML文件。我没写头。
<bean id="geli" class="test.GeLi"/>
<bean id="moattack" class="test.MoAttack">
<property name="geli" ref="geli"/>
</bean>
</beans>
我的test类
package test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Test {
public static void main(String[] args) {
ApplicationContext ac=new ClassPathXmlApplicationContext("applicationContext.xml");
MoAttack s1=(MoAttack)ac.getBean("moattack");
GeLi s2=(GeLi)ac.getBean("geli");
}
}                              
小弟在线等回复,希望大虾们帮帮我