记录spring加载方式
context = new ClassPathXmlApplicationContext("beans.xml")
?
而另一种指定文件名的加载方式
?
String path[]={appPath1+"applicationContext.xml",appPath1+"handerContext.xml"};
ctx = new FileSystemXmlApplicationContext(
path
);
?
关于 spring bean 的使用,都在spring 容易中有定义才允许使用spring bean
例如在handerContext.xml 中定义srping bean
最后使用?ctx.getBean(name);去获取这个bean 去操作。
整个系统大部分的关键类都交由spring去托管,如使用了注释 类似@Resource 或者@Service 等都必须在
? ? <context:component-scan base-package="com"> ?
? ? ? ? ?<context:include-filter type="regex" expression="com/.game/.dao/.impl.*"/> ?
? ? ? ? ?<context:exclude-filter type="regex" expression="com/.game/.service.*"/> ?
? ? ? ? ?<context:exclude-filter type="regex" expression="com/.game/.function.*"/> ?
? ? ? ? ?<context:exclude-filter type="regex" expression="com/.game/.service/.impl..*"/> ?
? ? </context:component-scan> ?
中有定义才行。