引入依赖包
<dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.11</version>
</dependency>
编写如下java代码:
import org.reflections.Reflections;
import java.lang.annotation.Annotation;
public class Main {
public static void main(String[] args) {
new Reflections("org.springframework")
.getSubTypesOf(Annotation.class)
.stream()
.map(clazz->clazz.getName())
.sorted()
.forEach(System.out::println);
}
}
即可打印出所有的注解
org.springframework.beans.factory.annotation.Autowired
org.springframework.beans.factory.annotation.Configurable
org.springframework.beans.factory.annotation.Lookup
org.springframework.beans.factory.annotation.Qualifier
org.springframework.beans.factory.annotation.Required
org.springframework.beans.factory.annotation.Value
org.springframework.cache.annotation.CacheConfig
org.springframework.cache.annotation.CacheEvict
org.springframework.cache.annotation.CachePut
org.springframework.cache.annotation.Cacheable
org.springframework.cache.annotation.Caching
org.springframework.cache.annotation.EnableCaching
org.springframework.context.annotation.Bean
org.springframework.context.annotation.ComponentScan
org.springframework.context.annotation.ComponentScan$Filter
org.springframework.context.annotation.ComponentScans
org.springframework.context.annotation.Conditional
org.springframework.context.annotation.Configuration
org.springframework.context.annotation.DependsOn
org.springframework.context.annotation.Description
org.springframework.context.annotation.EnableAspectJAutoProxy
org.springframework.context.annotation.EnableLoadTimeWeaving
org.springframework.context.annotation.EnableMBeanExport
org.springframework.context.annotation.Import
org.springframework.context.annotation.ImportResource
org.springframework.context.annotation.Lazy
org.springframework.context.annotation.Primary
org.springframework.context.annotation.Profile
org.springframework.context.annotation.PropertySource
org.springframework.context.annotation.PropertySources
org.springframework.context.annotation.Role
org.springframework.context.annotation.Scope
org.springframework.context.event.EventListener
org.springframework.core.annotation.AliasFor
org.springframework.core.annotation.Order
org.springframework.format.annotation.DateTimeFormat
org.springframework.format.annotation.NumberFormat
org.springframework.jmx.export.annotation.ManagedAttribute
org.springframework.jmx.export.annotation.ManagedMetric
org.springframework.jmx.export.annotation.ManagedNotification
org.springframework.jmx.export.annotation.ManagedNotifications
org.springframework.jmx.export.annotation.ManagedOperation
org.springframework.jmx.export.annotation.ManagedOperationParameter
org.springframework.jmx.export.annotation.ManagedOperationParameters
org.springframework.jmx.export.annotation.ManagedResource
org.springframework.lang.NonNull
org.springframework.lang.NonNullApi
org.springframework.lang.NonNullFields
org.springframework.lang.Nullable
org.springframework.lang.UsesJava7
org.springframework.lang.UsesJava8
org.springframework.lang.UsesSunHttpServer
org.springframework.lang.UsesSunMisc
org.springframework.objenesis.instantiator.annotations.Instantiator
org.springframework.scheduling.annotation.Async
org.springframework.scheduling.annotation.EnableAsync
org.springframework.scheduling.annotation.EnableScheduling
org.springframework.scheduling.annotation.Scheduled
org.springframework.scheduling.annotation.Schedules
org.springframework.stereotype.Component
org.springframework.stereotype.Controller
org.springframework.stereotype.Indexed
org.springframework.stereotype.Repository
org.springframework.stereotype.Service
org.springframework.validation.annotation.Validated