ApplicationListenerMyEventOrder>> { ... }When dispatching a event, the signature of your listener is used to determine if it matches said incoming event.
Due to type erasure your need to publish a event that resolves the generics parameter your would filter on, something like MyOrderEvent extends MyEvent. There might be workarounds and we is happy to revisit the signature matching algorithm if the community thinks it W Orthwhile.
Annotation
Common notes in annotation:
@Componet describe a bean in spring
@Repository identify the class of the Data Access Layer (DAO layer) as a bean in spring
@Service identify the class of the business Layer (service layer) as a bean in spring
(1), The configuration implicitly registers multiple processors that resolve annotations, such as: AutowiredAnnotationBeanPostProcessor Commonannotationbeanpostprocessor PersistenceAnnotationBeanPostProcessor Requiredannotationbeanpostprocessor In fact, annotations themselves do nothing, as with XML, only play a role in configuration, mainly in the back of the powerful processor which includes so configured
(2), @Component, @Repository, @Serv
On a whim, looking at spring's source code for two days, I want to write a simple spring using annotation injection!! Spring's annotation injection method gives us a very convenient benefit! Everyone should understand the injection principle of spring, write a very simple example of using annotations to inject, make a
Spring 2.5 introduces MVC controllers based on Annotation configuration. This short article describes how to migrate your spring 2.0 application to spring 2.5, at least MVC-related applications.
First make sure that you have placed the spring-webmvc.jar in your classpath, d
@Component, @Service, @Controller, @Repository annotated classes, and incorporate these classes into the spring container for management. The following is a scan component that introduces componentwhere Base-package is the package that needs to be scanned (with all child packages)1, @Service for labeling business layer components2. @Controller for labeling Contro
The content of this article is a summary of the online, only to do the study.
Spring Annotation-based configuration @Required Annotation The setter method applied to bean properties. Indicates that the affected bean must be placed in the XML configuration file when it is configured, or the container throws a Beaninitialzationexception exception. @Autowired Anno
, applicationcontext.xml Add configuration (similar to the thing configuration)turn on the annotation function of the cache, otherwise the annotations will not take effect - Cache:annotation-driven/> declaring the cache manager - BeanID= "CacheManager"class= "Org.springframework.cache.ehcache.EhCacheCacheManager"> Propertyname= "CacheManager"ref= "Ehcachefactory"> Property> Bean> Specify the factory class
To use annotation steps:1) First introduce the context namespacexmlns:context= "Http://www.springframework.org/schema/context"2) Turn on annotation scanning3) using annotationsThe object is added to the IOC container by means of annotations . Create objects and manipulate object dependencies, related annotations:@Component specifies that an object be added to the IOC container@Repository function with @comp
Description
Annotations are a class in spring, using the @+ annotation nameIn development, annotations can be used instead of XML configurations. more efficient and quick.If you make the annotation effective, you configure the namespace's declaration and scan information in the XML.
@Component replaces IOC configuration (bean) in XML
Let's give an example to
Implement AOP programming using spring annotations and XMLTo implement the AOP programming annotation method, follow these steps:
1) Introduce jar files related to aop first (excellent aspectj aop components)
Spring-aop-3.2.5.RELEASE.jar [spring3.2 source code]
Aopalliance. jar [spring2.5 source code/lib/aopalliance]
Aspectjweaver. jar [spring2.5 source code/lib/
A problem, in a SPRINGMVC project, set up the transaction, and then add the @transactional annotation on the service, as long as you add this annotation, the service cannot be created successfully by spring, error creating bean With name xxx or something. Engaged for a long
AnnotationIs a special metadata syntax in Java. Spring supports annotation for Object Instantiation and assembly.
Use Annotation to add the context namespace (yellow part) to the Spring configuration xml ):
Add the
Postprocessor: "processor" after bean Initialization is complete"
@ Autowired can be
Description and Differencespring4.1 provides annotations (annotation-based)-based configuration, which we can use to complete injection dependencies. In Java code, you can use @Resource or @autowired annotations to line-inject. Although both @resource and @autowired can be used to complete the injection dependency, there is a difference between them. First Look at:A. @Resource By default is assembled by name, only if the bean that matches the name is
Summary:When using MyBatis, a series of DAO interfaces can be configured through Mybatis-spring Mapperfactorybean, and Mapperfactorybean GetObject method can return the dynamic proxy class corresponding to the DAO interface. The implementation class of the DAO interface is actually generated by defaultsqlsession in a dynamic proxy manner. And when there are many DAO classes, you can implement Mapperfactorybean objects and reduce configuration by confi
database table is automatically growing, add a piece of data now and want to get the ID of this data autogrow, as followsDAO layerUsegeneratedkeys=true: Gets the primary key generated by the databasekeyproperty= "id": The id attribute of the user Param object to which the primary key value is stored@Insert ("Insert into user (name) values (#{name})") @Options (Usegeneratedkeys= true, keyproperty="ID") publicint Add ( User param);Service LayerNew Use
When the jar exported from a project using annotation is running, the @ service modified class cannot be found. However, there is no problem with the execution in the project. The following error is reported:Caused by: org. springframework. Beans. Factory. nosuchbeandefinitionexception: No bean named 'wikicategorymigrateservicice 'is defined
Solution:1. Define bean in XML. In this way,
The spring2.5 version provides annotated dependency injection functionality that can be reduced to XML configuration.The main use isAnnotationconfigapplicationcontext: An annotation configuration contextAutowiredannotationbeanpostprocessor:spring provides a beanpostprocessor implementation for this purpose to check whether the current object has @autowired-labeled dependency injection.In addition to using @autowired in the project, you can choose some
Spring's dependency check function can only check all attributes of Certain types. It cannot only check specific attributes and is not flexible enough. Generally, we only need to check whether specific attributes are set, rather than all attributes of a specific type.
Requiredannotationbeanpostprocessor is a post-processor of spring bean. It checks whether all bean attributes with the @ required annotation
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.