Spring all annotations, as long as you want to learn, you can get to

Source: Internet
Author: User

There are too many annotations recently in Spring Spring, there is no systematic learning scheme. Only one learns one, and here a piece of code is written to get these annotations.

First, see

Reference Reference http://www.cnblogs.com/davidwang456/p/4432410.html

This guy sums up quite a lot.

But brothers with obsessive-compulsive disorder can continue to look down.

1spring-contextorg.springframework.scheduling.annotation.schedulesorg.springframework.scheduling.annotation.enableschedul Ingorg.springframework.scheduling.annotation.Asyncorg.springframework.scheduling.annotation.Scheduledorg.springframework . Scheduling.annotation.EnableAsyncorg.springframework.context.annotation.Lazyorg.springframework.context.annotation.Impor TResourceorg.springframework.context.annotation.EnableLoadTimeWeavingorg.springframework.context.annotation.PropertySourc Eorg.springframework.context.annotation.Importorg.springframework.context.annotation.Scopeorg.springframework.context.ann Otation. Configurationorg.springframework.context.annotation.Descriptionorg.springframework.context.annotation.Beanorg.springframe Work.context.annotation.DependsOnorg.springframework.context.annotation.Roleorg.springframework.context.annotation.Proper TySourcesorg.springframework.context.annotation.ComponentScansorg.springframework.context.annotation.Profileorg.springfra Mework.context.annotation. Primaryorg.springframework.context.annotation.EnableAspectJAutoProxyorg.springframework.context.annotation.Conditionalorg . springframework.context.annotation.componentscanorg.springframework.context.annotation.componentscan$ Filterorg.springframework.context.annotation.EnableMBeanExportorg.springframework.context.event.EventListenerorg.springfr Amework.validation.annotation.validatedorg.springframework.jmx.export.annotation.managedresourceorg.springframework.jmx.e Xport.annotation.ManagedNotificationorg.springframework.jmx.export.annotation.ManagedOperationParameterorg.springframewor K.jmx.export.annotation.managedoperationorg.springframework.jmx.export.annotation.managednotificationsorg.springframework . jmx.export.annotation.ManagedAttributeorg.springframework.jmx.export.annotation.ManagedMetricorg.springframework.jmx.exp Ort.annotation.ManagedOperationParametersorg.springframework.cache.annotation.Cachingorg.springframework.cache.annotation . CacheEvictorg.springframework.cache.annotation.EnAbleCachingorg.springframework.cache.annotation.Cacheableorg.springframework.cache.annotation.CachePutorg.springframework . cache.annotation.CacheConfigorg.springframework.format.annotation.NumberFormatorg.springframework.format.annotation.Date TimeFormatorg.springframework.stereotype.Controllerorg.springframework.stereotype.Repositoryorg.springframework.stereotyp E. Serviceorg.springframework.stereotype.component2spring-weborg.springframework.web.bind.annotation.crossoriginorg.springfr Amework.web.bind.annotation.RequestHeaderorg.springframework.web.bind.annotation.RequestParamorg.springframework.web.bind . Annotation. ResponseStatusorg.springframework.web.bind.annotation.MatrixVariableorg.springframework.web.bind.annotation.ModelAttribut Eorg.springframework.web.bind.annotation.ExceptionHandlerorg.springframework.web.bind.annotation.CookieValueorg.springfra Mework.web.bind.annotation.PostMappingorg.springframework.web.bind.annotation.RequestPartorg.springframework.web.bind.ann Otation. RequestmapPingorg.springframework.web.bind.annotation.GetMappingorg.springframework.web.bind.annotation.RequestBodyorg.springframew Ork.web.bind.annotation.InitBinderorg.springframework.web.bind.annotation.PatchMappingorg.springframework.web.bind.annota tion. Mappingorg.springframework.web.bind.annotation.SessionAttributeorg.springframework.web.bind.annotation.RestControllerorg . SPRINGFRAMEWORK.WEB.BIND.ANNOTATION.CONTROLLERADVICEORG.SPRINGFRAMEWORK.WEB.BIND.ANNOTATION.SESSIONATTRIBUTESORG.SPRINGF Ramework.web.bind.annotation.ResponseBodyorg.springframework.web.bind.annotation.RestControllerAdviceorg.springframework . web.bind.annotation.RequestAttributeorg.springframework.web.bind.annotation.DeleteMappingorg.springframework.web.bind.an notation. PutMappingorg.springframework.web.bind.annotation.PathVariableorg.springframework.web.context.annotation.SessionScopeorg . springframework.web.context.annotation.requestscopeorg.springframework.web.context.annotation.applicationscope3spring-we Bmvcorg.springframewoRk.web.servlet.config.annotation.EnableWebMvc 

  

Here is a list of 3 jar annotations, all the annotations in the jar, mom no longer worry about my study is missing.

Get the method code as follows

 Packagecom.co.example;Importjava.util.ArrayList;Importjava.util.Enumeration;Importjava.util.List;ImportJava.util.jar.JarEntry;ImportJava.util.jar.JarFile;Importcom.google.common.collect.Lists; Public classPackagetest {/*** Get all classes under a package from the jar * *@paramjarpath * Jar file path *@paramChildpackage * Whether to traverse the child package *@returnthe full name of the class*/    Private StaticList<string> Getclassnamebyjar (String jarpath,Booleanchildpackage) {List<String> myClassName =NewArraylist<string>(); String[] Jarinfo= Jarpath.split ("!"); String Jarfilepath= Jarinfo[0].substring (Jarinfo[0].indexof ("/")); String PackagePath= jarinfo[1].substring (1); Try(Jarfile jarfile =Newjarfile (Jarfilepath);) {Enumeration<JarEntry> Entrys =jarfile.entries ();  while(Entrys.hasmoreelements ()) {Jarentry Jarentry=entrys.nextelement (); String EntryName=Jarentry.getname (); if(Entryname.endswith (". Class"))) {                    if(childpackage) {if(Entryname.startswith (PackagePath)) {EntryName= Entryname.replace ("/", "."). SUBSTRING (0, Entryname.lastindexof (".")));                        Myclassname.add (EntryName); }                    } Else {                        intindex = Entryname.lastindexof ("/");                        String Mypackagepath; if(Index! =-1) {Mypackagepath= entryname.substring (0, index); } Else{Mypackagepath=EntryName; }                        if(Mypackagepath.equals (PackagePath)) {EntryName= Entryname.replace ("/", "."). SUBSTRING (0, Entryname.lastindexof (".")));                        Myclassname.add (EntryName); }                    }                }            }        } Catch(Exception e) {e.printstacktrace (); }        returnmyClassName; }    /*** Search for the package from all jars and get all classes under the package * *@paramURLs * URL Collection *@paramPackagePath * Package path *@paramChildpackage * Whether to traverse the child package *@returnthe full name of the class*/    Private StaticList<string> Getclassnamebyjars (string[] URLs, String PackagePath,Booleanchildpackage) {List<String> myClassName =NewArraylist<string>(); if(URLs! =NULL) {             for(inti = 0; i < urls.length; i++) {String URLPath=Urls[i]; //You do not have to search the classes folder                if(Urlpath.endswith ("classes/")) {                    Continue; } String Jarpath= URLPath + "!" +PackagePath;            Myclassname.addall (Getclassnamebyjar (Jarpath, childpackage)); }        }        returnmyClassName; }     Public Static voidMain (string[] args) {List<String> annotationslist =lists.newarraylist (); String BasePath= "D:/repository/maven/org/springframework"; List<String> jars =lists.newarraylist (); //Jars.add (basepath+ "/spring-context/4.3.8.release/spring-context-4.3.8.release.jar"); //Jars.add (basepath+ "/spring-web/4.3.8.release/spring-web-4.3.8.release.jar");Jars.add (basepath+ "/spring-webmvc/4.3.8.release/spring-webmvc-4.3.8.release.jar"); String[] Strarr=Newstring[jars.size ()]; Jars.toarray (Strarr);

String packagepath= "org"; There's a space here.
list<string> className = Getclassnamebyjars (Strarr, PackagePath, true);

 for(String cn:classname) {Try{Class<?> Onwclass =Class.forName (CN); if(Onwclass! =NULL){                                        BooleanANNOTATIONFLG =onwclass.isannotation (); if(ANNOTATIONFLG) {Annotationslist.add (CN); }                }            } Catch(ClassNotFoundException e) {Continue; }Catch(Noclassdeffounderror f) {Continue; }        }                 for(String str:annotationslist) {System.out.println (str); }            }    }

You want to get more annotations in the jar:

1. Modify the BasePath in the main method, that is, the location of the local jar.

2. Modify the PackagePath, org, or COM in the main method

Reference reference

Get a partial code reference for all class names http://blog.csdn.net/wangpeng047/article/details/8206427

Spring all annotations, as long as you want to learn, you can get to

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.