Spring
共 6 篇文章
Spring 依赖注入
<bean id="aaa" clas="aaa的路径"> <bena id="service" calss="service路径"> <property name="aaa" ref=''aaa'>ref是从容器里实例化后找到对应的bean,通过反射技术给了这个属性 </bean>
2013-09-20 19:50 · Spring
Spring Bean的作用域
在每个Spring ioc容器中一个bean定义只有一个对象实例, 默认情况下会在容器启动时初始化bean,但我们可也指定benan节点 的lazy-init=“true” 来延迟初始化bean,这时候,只有第一次获取bean会 才初始化bean,如: <bean id="XXX" class="cn.itcast orderServiceBean" lazy-init="true"> 如果想对所有bean的应用延迟初始化,可也在根接点beans设置default-lazy=init=“true” 如下:<bean default-lazy-init="true"> .prototype<b…
2013-09-20 10:48 · Spring
实例化Spring容器
实例化Spring容易的两种方法 在类路径下寻找配置文件 ApplicationContext ctx = new ClassPathXmlApplicationContext(new String[]{"beans.xml"}) 在文件系统路径下寻找配置文件 ApplicationContext ctx = new fileSystemXmlApplicationContext(new String[]{"d:\\beans.xml"})
2013-09-02 22:02 · Spring
为什么要使用Spring
1.降低组件之间的耦合度,实现软件各层直接的解耦 controlle-service-dao 2.Spring 提供了:事物管理服务、JMS服务器、 Spring core 核心服务 、持久化服务、其他 3.容器提供了单例模式,开发人员不需要自己编写实例代码 4.容器提供了AOP技术,利用他很容易实现如权限拦截,运行期间监控功能。 5.容器提供了辅助类,jdbctemplate,hibernatetemplate 6.容器提供了主流框架的集成支持