<context annotation-config />标签意义:
该标签隐式的向Spring容器注册了:
AutowiredAnnotationBeanPostProcessor CommondAnnotationBeanPostProcessor
PersistenceAnnotationBeanPostProcessor RequiredAnnotationBeanPostProcessor这四个BeanPostProcessor.
AutowiredAnnotationBeanPostProcessor CommondAnnotationBeanPostProcessor
PersistenceAnnotationBeanPostProcessor RequiredAnnotationBeanPostProcessor这四个BeanPostProcessor.
1.AutowiredAnnotationBeanPostProcessor:主要是使用@AutoWired注解时,必须提前向Spring容器注册这个BeanPostprocessor
传统的配置方式:<bean class="org.springframework.beans.factory.annotation. AutowiredAnnotationBeanPostProcessor "/>
传统的配置方式:<bean class="org.springframework.beans.factory.annotation. AutowiredAnnotationBeanPostProcessor "/>
2.CommondAnnotationBeanPostprocessor:主要是使用@Resource、@PostConstruct、@Predestory等注解时,必须提前向Spring容器注册。
传统配置方式:<bean class="org.springframework.beans.factory.annotation.CommondAnnotationBeanPostprocessor"/>
传统配置方式:<bean class="org.springframework.beans.factory.annotation.CommondAnnotationBeanPostprocessor"/>
3.PersistenceAnnotationBeanPostProcessor :主要是使用@PersistenceContext注解时,必须提前向Spring容器注册。
传统配置方式:<bean class="org.springframework.beans.factory.annotation.PersistenceAnnotationBeanPostProcessor"/>
传统配置方式:<bean class="org.springframework.beans.factory.annotation.PersistenceAnnotationBeanPostProcessor"/>
4.RequiredAnnotationBeanPostProcessor:主要是使用@Required注解时,必须提前向Spring容器注册。
传统配置方式:<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/>
传统配置方式:<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/>
一般来说,@Autowired注解比较常用,传统配置方式有点繁琐,而这种隐式配置方式就可以帮我们很容易的搞定。
不过使用注解,我们一般都会配置扫描包路径:<context: component-scan base-package=com.xxx.xxx />
其实,给配置已经包含了自动注入上述Processor的功能,所以,配置了包扫描之后,<context annotation-config />就可以移除了。
不过使用注解,我们一般都会配置扫描包路径:<context: component-scan base-package=com.xxx.xxx />
其实,给配置已经包含了自动注入上述Processor的功能,所以,配置了包扫描之后,<context annotation-config />就可以移除了。
相关推荐
<context:annotation-config /> <!-- <bean id="sessionFactory"--> <!-- class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">--> <!-- <property name="configLocation"--> <!-- value=...
<context:annotation-config/> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass" value="com.mysql.jdbc.Driver"></property> <property name="jdbc...
<context:annotation-config></context:annotation-config> <context:component-scan base-package="org.whvcse"></context:component-scan> <tx:annotation-driven transaction-manager="txManager" /> <!-- ...
<context:annotation-config/> <!-- 扫描包 --> <context:component-scan base-package="com.org"/> <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver...
<context:annotation-config/> <context:component-scan base-package="com.org.*" /> <bean id="jspViewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property...
<context:annotation-config /> <context:component-scan base-package="com.mvc" /> <mvc:annotation-driven /> <mvc:resources mapping="/resources/**" location="/resources/" /> <mvc:default-servlet-...
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" p:order="0"> <property name="interceptors"> <list> <ref bean="doubleSubmitInterceptor"/> </list> ...
<tx:annotation-driven transaction-manager="transactionManager"/> 2,测试代码 1,Service类 @Service public class InsertUserService { @Resource private SessionFactory ...
<context:annotation-config/> <!-- 扫描包 --> <context:component-scan base-package="com.org.core"/> <bean id="jspViewResolver" class="org.springframework.web.servlet.view....
10. <context:annotation-config /> 11. <!-- 把标记了@Controller注解的类转换为bean --> 12. <context:component-scan base-package="com.mvc.controller" /> 13. <!-- 启动Spring MVC的注解功能,...
NULL 博文链接:https://stillcoolme.iteye.com/blog/2314109
</beans><context:annotation-config/> <context:component-scan base-package="com.spring.*"/> 两行为开启spring的注解配置 <aop:aspect id="aspect" ref="logIntercepter"> 引入具体的AOP操作类 <aop:pointcut ...
学习spring组件扫描(Component Scanning)的代码 ...<context:annotation-config /> <context:component-scan base-package="com.test"></context:component-scan> 2.在需要装配的类的上面全部加上@Component
即解决了@Controller注解的使用前提配置<context:annotation-config/>是对包进行扫描,实现注释驱动Bean定义,同时将bean自动注入容器中使用。即解决了@Controller标识的类的bean的注入和使用。
<tx:annotation-driven transaction-manager="txManager"/> * 创建dao层共同的接口,放置在cn.itcast.crm.dao下 public interface ICommonDao<T> { public void save(T entity); } * ...
spring mvc aop <context:annotation-config />
<context:annotation-config/> <context:property-placeholder location="classpath:system.properties"/> <!--客户端配置--> <bean id="rpcClient" class="com.yingjun.rpc.client.RPCClient"> ...
dubbo提供者配置文件,扫描可用,先要打开扫描注释<context:annotation-config />
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>weixin</servlet-name> <servlet-class>...