接口 Profiles
- 函数接口:
- 这是一个函数接口, 因此可用作 lambda 表达式或方法引用的赋值目标。
@FunctionalInterface public interface Profiles
Profile predicate that may be accepted by anEnvironment.May be implemented directly or, more usually, created using the
of(...)factory method.- 从以下版本开始:
- 5.1
- 作者:
- Phillip Webb, Sam Brannen
方法详细资料
matches
boolean matches(Predicate<String> activeProfiles)
Test if thisProfilesinstance matches against the given active profiles predicate.- 参数:
activeProfiles- a predicate that tests whether a given profile is currently active
of
static Profiles of(String... profiles)
Create a newProfilesinstance that checks for matches against the given profile strings.The returned instance will match if any one of the given profile strings matches.
A profile string may contain a simple profile name (for example
"production") or a profile expression. A profile expression allows for more complicated profile logic to be expressed, for example"production & cloud".The following operators are supported in profile expressions.
!- A logical NOT of the profile or profile expression&- A logical AND of the profiles or profile expressions|- A logical OR of the profiles or profile expressions
Please note that the
&and|operators may not be mixed without using parentheses. For example"a & b | c"is not a valid expression; it must be expressed as"(a & b) | c"or"a & (b | c)".As of Spring Framework 5.1.17, two
Profilesinstances returned by this method are considered equivalent to each other (in terms ofequals()andhashCode()semantics) if they are created with identical profile strings.- 参数:
profiles- the profile strings to include- 返回:
- a new
Profilesinstance