2014年2月12日

Spring @ Component 的作用

摘要: 1、@controller 控制器(注入服务) 2、@service 服务(注入dao) 3、@repository dao(实现dao访问) 4、@component (把普通pojo实例化到spring容器中,相当于配置文件中的) @Component,@Service,@Controller,@Repository注解的类,并把这些类纳入进spring容器中管理。下面写这个是引入component的扫描组件其中base-package为需要扫描的包(含所有子包) 1、@Service用于标注业务层组件 2、@Controller用于标注控制层组件(如struts中的action) 3、@ 阅读全文

posted @ 2014-02-12 09:59 Step-BY-Step 阅读(605) 评论(0) 推荐(0) 编辑

[转载]Spring Web MVC Framework

摘要: Required Configuration You need to map requests that you want the DispatcherServlet to handle, by using a URL mapping in the web.xml file. The following is an example to show declaration and mapping for HelloWebDispatcherServlet example: Spring MVC Application HelloWeb org.... 阅读全文

posted @ 2014-02-12 09:54 Step-BY-Step 阅读(275) 评论(0) 推荐(0) 编辑

[转载]Spring Java Based Configuration

摘要: @Configuration & @Bean AnnotationsAnnotating a class with the @Configuration indicates that the class can be used by the Spring IoC container as a source of bean definitions. The @Bean annotation tells Spring that a method annotated with @Bean will return an object that should be registered as a 阅读全文

posted @ 2014-02-12 09:43 Step-BY-Step 阅读(344) 评论(0) 推荐(0) 编辑

[转载]Spring Annotation Based Configuration

摘要: Annotation injection is performed before XML injection, thus the latter configuration will override the former for properties wired through both approaches. Annotation wiring is not turned on in the Spring container by default. So, before we can use annotation-based wiring, we will need to enable it 阅读全文

posted @ 2014-02-12 09:22 Step-BY-Step 阅读(374) 评论(0) 推荐(0) 编辑

[转载]Spring Beans Auto-Wiring

摘要: Autowiring ModesYou have learnt how to declare beans using the element and inject with using and elements in XML configuration file. The Spring container can autowire relationships between collaborating beans without using and elements which helps cut down on the amount of XML configuration yo... 阅读全文

posted @ 2014-02-12 08:56 Step-BY-Step 阅读(410) 评论(0) 推荐(0) 编辑

[转载]Spring Bean Definition Inheritance

摘要: Following is the configuration file Beans.xml where we defined "helloWorld" bean which has two properties message1 and message2. Next "helloIndia" bean has been defined as a child of "helloWorld" bean by using parent attribute. The child bean inherits message2 property 阅读全文

posted @ 2014-02-12 08:09 Step-BY-Step 阅读(326) 评论(0) 推荐(0) 编辑

[转载]Spring Bean Configuration Inheritance

摘要: 转自:http://www.mkyong.com/spring/spring-bean-configuration-inheritance/In Spring, the inheritance is supported in bean configuration for a bean to share common values, properties or configurations.A child bean or inherited bean can inherit its parent bean configurations, properties and some attribute 阅读全文

posted @ 2014-02-12 08:02 Step-BY-Step 阅读(254) 评论(0) 推荐(0) 编辑

[转载]Spring Autowire自动装配介绍

摘要: 转自:http://www.cnblogs.com/zhishan/p/3190757.html在应用中,我们常常使用标签为JavaBean注入它依赖的对象。但是对于一个大型的系统,这个操作将会耗费我们大量的资源,我们不得不花费大量的时间和精力用于创建和维护系统中的标签。实际上,这种方式也会在另一种形式上增加了应用程序的复杂性,那么如何解决这个问题呢?Spring为我们提供了一个自动装配的机制,尽管这种机制不是很完善,但是在应用中结合标签还是可以大大的减少我们的劳动强度。前面提到过,在定义Bean时,标签有一个autowire属性,我们可以通过指定它来让容器为受管JavaBean自动注入依赖对 阅读全文

posted @ 2014-02-12 08:01 Step-BY-Step 阅读(152) 评论(0) 推荐(0) 编辑

导航