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.context.annotation.Import;
027import org.springframework.core.annotation.AliasFor;
028
029/**
030 * Import and apply the specified auto-configuration classes. Applies the same ordering
031 * rules as {@code @EnableAutoConfiguration} but restricts the auto-configuration classes
032 * to the specified set, rather than consulting {@code spring.factories}.
033 * <p>
034 * Can also be used to {@link #exclude()} specific auto-configuration classes such that
035 * they will never be applied.
036 * <p>
037 * Generally, {@code @EnableAutoConfiguration} should be used in preference to this
038 * annotation, however, {@code @ImportAutoConfiguration} can be useful in some situations
039 * and especially when writing tests.
040 *
041 * @author Phillip Webb
042 * @author Andy Wilkinson
043 * @since 1.3.0
044 */
045@Target(ElementType.TYPE)
046@Retention(RetentionPolicy.RUNTIME)
047@Documented
048@Inherited
049@Import(ImportAutoConfigurationImportSelector.class)
050public @interface ImportAutoConfiguration {
051
052        /**
053         * The auto-configuration classes that should be imported. This is an alias for
054         * {@link #classes()}.
055         * @return the classes to import
056         */
057        @AliasFor("classes")
058        Class<?>[] value() default {};
059
060        /**
061         * The auto-configuration classes that should be imported. When empty, the classes are
062         * specified using an entry in {@code META-INF/spring.factories} where the key is the
063         * fully-qualified name of the annotated class.
064         * @return the classes to import
065         */
066        @AliasFor("value")
067        Class<?>[] classes() default {};
068
069        /**
070         * Exclude specific auto-configuration classes such that they will never be applied.
071         * @return the classes to exclude
072         */
073        Class<?>[] exclude() default {};
074
075}