In host based configuration Spring In the configuration file , You may see <context:annotation-config/> Such a configuration , His function is to Spring Vessel registration
AutowiredAnnotationBeanPostProcessor、CommonAnnotationBeanPostProcessor、
PersistenceAnnotationBeanPostProcessor as well as RequiredAnnotationBeanPostProcessor this 4 individual BeanPostProcessor.
Register here 4 individual BeanPostProcessor The role of , So that your system can recognize the corresponding annotations .
for example :
If you want to use @Autowired annotation , Then it must be done in advance Spring Declaration in container AutowiredAnnotationBeanPostProcessor Bean. The traditional way of declaration is as follows
<bean class="org.springframework.beans.factory.annotation. AutowiredAnnotationBeanPostProcessor "/>
If you want to use @ Resource 、@ PostConstruct、@ PreDestroy When you wait for a comment, you have to state CommonAnnotationBeanPostProcessor
If you want to use @PersistenceContext annotation , It must be stated that PersistenceAnnotationBeanPostProcessor Of Bean.
If you want to use @Required Annotations , It must be stated that RequiredAnnotationBeanPostProcessor Of Bean. Again , The traditional way to make a statement is as follows :
<bean class="org.springframework.beans.factory.annotation.RequiredAnnotationBeanPostProcessor"/>
Generally speaking , We still use these annotations more often , In especial Antowired Annotations , It's often used in automatic injection , So if you always need to configure one by one according to the traditional way, it seems a little cumbersome and unnecessary , therefore spring Give us <context:annotation-config/> Simplified configuration of , Automatically complete the statement for you .
however , ha-ha , When we use annotations, we usually configure the scan package path option
<context:component-scan base-package=”XX.XX”/>
This configuration item also includes automatic injection of the above processor The function of , So when you use <context:component-scan/> after , It can be <context:annotation-config/> Removed .
Spring <context:annotation-config/> More articles about
- spring 2.5.6 error :Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher
When running a project delivered by a third party company , appear : Caused by: java.lang.IllegalStateException: Context namespace element 'annot ...
- Spring To configure Annotation <context:annotation-config> and <context:component-scan> The interpretation and difference of labels
Spring Turn on Annotation <context:annotation-config> and <context:component-scan> Interpretation and distinction <cont ...
- Spring Configuration context:annotation And 、component-scan as well as annotation-driven
spring boot It helps us hide a lot of details , Some configurations spring boot It's all on , So when we look at legacy projects using spring When you encounter problems, you must check carefully <!-- context:annotat ...
- Mingyang.net:org.springframework.context.annotation.ConflictingBeanDefinitionException
org.springframework.context.annotation.ConflictingBeanDefinitionException: Annotation-specified bean ...
- 【 original 】 Uncle, experience sharing (16)Context namespace element 'component-scan' and its parser class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher
Try to run an old project today , After the configuration is completed, the compilation passes , As a result, the running time is wrong : org.springframework.beans.factory.BeanDefinitionStoreException: Une ...
- Realize the scheduling function running in the independent thread pool , be based on Spring and Annotation
Use Spring Annotations (@Scheduled) When declaring multiple schedules , Because of its default implementation mechanism , It will result in interference among multiple scheduling methods ( The simple understanding is that the schedule is not executed according to the configured time point ). To solve this problem, we tried to modify the thread pool size , however ...
- Context namespace element 'annotation-config' and its parser class [org.springframework.context.annotation.AnnotationConfigBeanDefinitionParser]
serious : Exception sending context initialized event to listener instance of class org.springframework.we ...
- Spring Security Java Config Preview-- official
Original address :[1]https://spring.io/blog/2013/07/02/spring-security-java-config-preview-introduction/ [2]https ...
- Alibaba Nacos Study ( Two ):Spring Cloud Nacos Config
Alibaba Nacos Study ( One ):Nacos Introduction and installation Alibaba Nacos Study ( Two ):Spring Cloud Nacos Config Alibaba Nacos Study ( 3、 ... and ):Spr ...
- class [org.springframework.context.annotation.ComponentScanBeanDefinitionParser] are only available on JDK 1.5 and higher
In the building SSM The project reported the following errors : 06-Oct-2019 11:55:52.109 Information [RMI TCP Connection(5)-127.0.0.1] org.apache.catalina. ...
Random recommendation
- 【HEOI2012】 pluck flowers BZOJ2743
Description Xiao Yunlan is Z Princess of the Kingdom , One of my hobbies is picking flowers . It's sunny today , The sun is shining , In the morning, the princess went to the new garden in the palace to pick flowers . The garden is big enough , To accommodate n A flower , There are flowers c Color ( Integers 1-c Express ), And the flowers are in a row ...
- win 8 in win7 matters needing attention
win8 in win7 Change the hard disk format gpt Format conversion to mbr Pattern When it comes to choosing to install to a disk , Because of the different types of disks , Will prompt :“ The selected disk uses GPT Partition form cannot install system ”. At this time, you need to reset the partition form ( ...
- RDBMS DML DDL
RDBMS RDBMS A relational database management system . RDBMS yes SQL The basis of , It's also the foundation of all modern database systems , such as MS SQL Server, IBM DB2, Oracle, MySQL ...
- Java 2D API - 2. Graphics introduction
Java 2D API Powerful and complex , But most of the time we just use java.awt.Graphcis Class . The following will cover most common applications . Graphics Methods in a class can be roughly divided into two categories : Draw ...
- IE browser How to turn off the annoying “ This site needs to run the following add ins :XXX. If you trust the site and the add in and allow it to run , Please click here ...
1. function gpedit.msc 2. Open user configuration in Open Group Policy —— Manage templates ——Windows Components ——Internet Explorer 3. choice “ close ActiveX Select enable prompt ”, Change its status to “ Enabled ...
- JavaScript In depth explanation of the prototype of
Understand the prototype A prototype is an object , Other objects can implement property inheritance through it . Any object can be an inheritance , All objects have a prototype by default , Because prototypes themselves are objects , So each archetype has another archetype of its own . Every object has a pro ...
- JavaScript Character set encoding and decoding
One . Character set 1) Characters and bytes (Character) Character is the general name of all kinds of characters and symbols , Including garbled code : One character corresponds to 1~n Bytes , One byte corresponds to 8 position , Everyone uses 0 or 1 Express . 2) Character set (Character Set) The character set is ...
- JS property descriptor
var myObject = { a:2 }; Object.getOwnpropertyDescriptor(myObject,"a"); { value:2, writable ...
- @Value("${xxxx}") The configuration and use of annotations
Usage in code Spring adopt @Value Annotation access *.porperties file code The content of , Then assign a value to Code Attribute . @Value("${code}") priv ...
- take ArcGIS Server Of JSON Turn into SHP file
# -*- coding: utf-8 -*- # -------------------------------------------------------------------------- ...