Simongs NOTE

[JAVA] @Conditional Annotation

2018-01-04

▣ 동작원리

▣ @Conditional Annotation

@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE, ElementType.METHOD})
public @interface Conditional {

	/**
	 * All `Condition`s that must `Condition#matches` match in order for the component to be registered.
	 */
	Class<? extends Condition>[] value();

}

▣ Condition Interface

public interface Condition {

	/**
	 * Determine if the condition matches.
	 */
	boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata);
}

▣ @Conditional 종류

@ConditionalOnMissingBean
@ConditionalOnBean
@ConditionalOnProperty
@ConditionalOnProperty
@ConditionalOnClass
@ConditionalOnMissingClass

Comments

Content