Alibabacloud.com offers a wide variety of articles about java spring annotations tutorial, easily find your java spring annotations tutorial information here online.
void SayHello () { System.out.println ("Hello World"); @Override public String toString () { return "user{" + "s= '" + S + ' \ ' + '} ';} }Iii. mixed use of XML and annotationsTwo ways to combine: generally using XML to register beans, using annotations for attribute injectionLet's start with some additional annotation configurations:(1) Configure the Bean initialization method and destroy method:*
do not spring, it is recommended to find some Java video tutorials to see. He gives us more options, and spring starts with the Applicationcontext.xmlelement to automatically assemble classes with spring annotations, OK, let's change the A1checkinthread class@Componentpubli
FileInputStream (path)); list = new arraylist3. After the preparation is done, the key point is to know that the Bank settlement is aware that the daily exchange needs to check in the clearing bank, then each bank check-in method is not the same, now we for A1, A2, B1 Bank first Good registration methodpublic class A1checkinthread implements Runnable {private static Logger Logger = Logger.getlogger (A1checkinthread.class) ; @Overridepublic void Run () {try {logger.info ("A1 sign in ...");A2, B3
map Import above the service layer Cachecontext 2. Springcache annotation @cacheable (value = "Accountcache")This annotation means that when this method is called, it is queried from a cache called Accountcache, and if not, the actual method (that is, querying the database) is executed, and the result of execution is cached, otherwise the object in the cache is returned. The key in the cache here is the parameter accountname,value is the account object. The "Accountcache" cache is the nam
=1userid=10username=tomListboardtopic (@RequestParam ("id")inttopicid,user User) TopicID binding to the ID of this URL parameter, you can use @RequestParam annotations to the entry to achieve the purpose @RequestParam (required=false): The parameter is not required, and the default is True @RequestParam (value= "id", required=falsethe optional type of Java base data type and String by default for the reques
, the Bean annotated as @ Primary will be the first candidate; otherwise, an exception @ Autowired is thrown and assembled by type by default, if you want to use name-based assembly, you can use it together with the @ Qualifier annotation. As follows: @ Autowired @ Qualifier ("personDaoBean") there are multiple instances used together with @ Resource assembled by name by default. Only beans with the same name cannot be found will be assembled by type. @ PostConstruct initialization annotation @
Spring common annotations use annotations to construct IoC containers. springioc
Construct an IoC Container Using annotations
Use annotations to register beans with Spring containers. You must register
For example, specify a pack
Spring annotation
1. Preparatory work(1) Import Common-annotations.jar(2) Import schema file file name is Spring-context-3.0.3.release.jar(3) Configuring in the Beans node of XML
2.xml Configuration Work
Note: This configuration implicitly registers multiple processors that resolve annotations, such as:
Autowiredannotationbeanpostprocessor
Commonannotationbe
XML configuration files are almost completely deprecated in spring boot, and the topic of this article is to analyze commonly used annotations.Spring was initially designed to address the intrusion of large enterprise frameworks such as EJBS into applications, so relying heavily on configuration files for "non-intrusive" pojo added functionality, but starting with spring 3.x, one of the most popular things
exception is thrown if it is not found3. If the type is specified, an exception is thrown when the unique bean matching the match is found in the context, cannot be found, or multiple occurrences are found4. If neither name is specified and type is not specified, the assembly is automatically byname; if there is no match, the fallback is a match for the original type, and if the match is automatically assembled;The difference between @Autowired and @resource:1, @Autowired and @resource can be u
is specified, an exception is thrown when the unique bean matching the match is found in the context, cannot be found, or multiple occurrences are found4. If neither name is specified and type is not specified, the assembly is automatically byname; if there is no match, the fallback is a match for the original type, and if the match is automatically assembled;The difference between @Autowired and @resource:1. Both @Autowired and @resource can be used to assemble beans. Both can be written on th
Explanation of annotations in reflection of Java programming and explanation of java programming annotations
The word "annotation" is a common topic in Java programming with a high appearance rate. Annotations were everywhere when
Java annotations provide information about the code and have no direct impact on the code they annotate. In this tutorial, we'll learn about Java annotations, how to customize annotations, annotate usage, and how to use reflection
to the Java EE), the default installation name for assembly, the name can be specified by the Name property, if the Name property is not specified, when the annotation is written on the field, the default name of the field name lookup, If the annotation is written on the setter method, the property name is assembled by default. When a bean matching the name cannot be found, it is assembled by type. However, it is important to note that if the Name pr
exception is thrown if it is not found3. If the type is specified, an exception is thrown when the unique bean matching the match is found in the context, cannot be found, or multiple occurrences are found4. If neither name is specified and type is not specified, the assembly is automatically byname; if there is no match, the fallback is a match for the original type, and if the match is automatically assembled;The difference between @Autowired and @resource:1, @Autowired and @resource can be u
) from the context is assembled, and an exception is thrown if it is not found3. If the type is specified, an exception is thrown when the unique bean matching the match is found in the context, cannot be found, or multiple occurrences are found4. If neither name is specified and type is not specified, the assembly is automatically byname; if there is no match, the fallback is a match for the original type, and if the match is automatically assembled;The difference between @Autowired and @resour
properties of the @enableautoconfiguration annotations to disable them.
Import org.springframework.boot.autoconfigure.*;Import org.springframework.boot.autoconfigure.jdbc.*;Import org.springframework.context.annotation.*;@Configuration@EnableAutoConfiguration (Exclude={datasourceautoconfiguration.class})public class Myconfiguration {
//...}
@Configuration
Spring Boot advocates
Reference: http://www.cnblogs.com/skywang12345/p/3344137.htmlHttp://www.cnblogs.com/taoxiaoji/archive/2011/01/19/1939651.htmlhttp://blog.csdn.net/tigerdsh/article/details/8848890Http://www.cnblogs.com/peida/archive/2013/04/24/3036689.htmlFirst you know what the annotations are, what to do, and when to use them.1. What is the annotation?That is, a description of the data. Providing a formal way for us to add information to our code is that we can easil
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.