001/* 002 * Copyright 2012-2017 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.boot.autoconfigure; 018 019import java.lang.annotation.Documented; 020import java.lang.annotation.ElementType; 021import java.lang.annotation.Inherited; 022import java.lang.annotation.Retention; 023import java.lang.annotation.RetentionPolicy; 024import java.lang.annotation.Target; 025 026import org.springframework.boot.SpringBootConfiguration; 027import org.springframework.boot.context.TypeExcludeFilter; 028import org.springframework.context.annotation.Bean; 029import org.springframework.context.annotation.ComponentScan; 030import org.springframework.context.annotation.ComponentScan.Filter; 031import org.springframework.context.annotation.Configuration; 032import org.springframework.context.annotation.FilterType; 033import org.springframework.core.annotation.AliasFor; 034 035/** 036 * Indicates a {@link Configuration configuration} class that declares one or more 037 * {@link Bean @Bean} methods and also triggers {@link EnableAutoConfiguration 038 * auto-configuration} and {@link ComponentScan component scanning}. This is a convenience 039 * annotation that is equivalent to declaring {@code @Configuration}, 040 * {@code @EnableAutoConfiguration} and {@code @ComponentScan}. 041 * 042 * @author Phillip Webb 043 * @author Stephane Nicoll 044 * @since 1.2.0 045 */ 046@Target(ElementType.TYPE) 047@Retention(RetentionPolicy.RUNTIME) 048@Documented 049@Inherited 050@SpringBootConfiguration 051@EnableAutoConfiguration 052@ComponentScan(excludeFilters = { 053 @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class), 054 @Filter(type = FilterType.CUSTOM, classes = AutoConfigurationExcludeFilter.class) }) 055public @interface SpringBootApplication { 056 057 /** 058 * Exclude specific auto-configuration classes such that they will never be applied. 059 * @return the classes to exclude 060 */ 061 @AliasFor(annotation = EnableAutoConfiguration.class) 062 Class<?>[] exclude() default {}; 063 064 /** 065 * Exclude specific auto-configuration class names such that they will never be 066 * applied. 067 * @return the class names to exclude 068 * @since 1.3.0 069 */ 070 @AliasFor(annotation = EnableAutoConfiguration.class) 071 String[] excludeName() default {}; 072 073 /** 074 * Base packages to scan for annotated components. Use {@link #scanBasePackageClasses} 075 * for a type-safe alternative to String-based package names. 076 * @return base packages to scan 077 * @since 1.3.0 078 */ 079 @AliasFor(annotation = ComponentScan.class, attribute = "basePackages") 080 String[] scanBasePackages() default {}; 081 082 /** 083 * Type-safe alternative to {@link #scanBasePackages} for specifying the packages to 084 * scan for annotated components. The package of each class specified will be scanned. 085 * <p> 086 * Consider creating a special no-op marker class or interface in each package that 087 * serves no purpose other than being referenced by this attribute. 088 * @return base packages to scan 089 * @since 1.3.0 090 */ 091 @AliasFor(annotation = ComponentScan.class, attribute = "basePackageClasses") 092 Class<?>[] scanBasePackageClasses() default {}; 093 094}