converter:
sourcedir: /a/b/c/d
继续深究,Environment的源码:
/*
-
Copyright 2002-2013 the original author or authors.
-
Licensed under the Apache License, Version 2.0 (the “License”);
-
you may not use this file except in compliance with the License.
-
You may obtain a copy of the License at
-
http://www.apache.org/licenses/LICENSE-2.0
-
Unless required by applicable law or agreed to in writing, software
-
distributed under the License is distributed on an “AS IS” BASIS,
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-
See the License for the specific language governing permissions and
-
limitations under the License.
*/
package org.springframework.core.env;
/**
-
Interface representing the environment in which the current application is running.
-
Models two key aspects of the application environment: profiles and
-
properties. Methods related to property access are exposed via the
-
{@link PropertyResolver} superinterface.
-
A profile is a named, logical group of bean definitions to be registered
-
with the container only if the given profile is active. Beans may be assigned
-
to a profile whether defined in XML or via annotations; see the spring-beans 3.1 schema
-
or the {@link org.springframework.context.annotation.Profile @Profile} annotation for
-
syntax details. The role of the {@code Environment} object with relation to profiles is
-
in determining which profiles (if any) are currently {@linkplain #getActiveProfiles
-
active}, and which profiles (if any) should be {@linkplain #getDefaultProfiles active
-
by default}.
-
Properties play an important role in almost all applications, and may
-
originate from a variety of sources: properties files, JVM system properties, system
-
environment variables, JNDI, servlet context parameters, ad-hoc Properties objects,
-
Maps, and so on. The role of the environment object with relation to properties is to
-
provide the user with a convenient service interface for configuring property sources
-
and resolving properties from them.
-
Beans managed within an {@code ApplicationContext} may register to be {@link
-
org.springframework.context.EnvironmentAware EnvironmentAware} or {@code @Inject} the
-
{@code Environment} in order to query profile state or resolve properties directly.
-
In most cases, however, application-level beans should not need to interact with the
-
{@code Environment} directly but instead may have to have {@code ${…}} property
-
values replaced by a property placeholder configurer such as
-
{@link org.springframework.context.support.PropertySourcesPlaceholderConfigurer
-
PropertySourcesPlaceholderConfigurer}, which itself is {@code EnvironmentAware} and
-
as of Spring 3.1 is registered by default when using
-
{@code context:property-placeholder/}.
-
Configuration of the environment object must be done through the
-
{@code ConfigurableEnvironment} interface, returned from all
-
{@code AbstractApplicationContext} subclass {@code getEnvironment()} methods. See
-
{@link ConfigurableEnvironment} Javadoc for usage examples demonstrating manipulation
-
of property sources prior to application context {@code refresh()}.
-
@author Chris Beams
-
@since 3.1
-
@see PropertyResolver
-
@see EnvironmentCapable
-
@see ConfigurableEnvironment
-
@see AbstractEnvironment
-
@see StandardEnvironment
-
@see org.springframework.context.EnvironmentAware
-
@see org.springframework.context.ConfigurableApplicationContext#getEnvironment
-
@see org.springframework.context.ConfigurableApplicationContext#setEnvironment
-
@see org.springframework.context.support.AbstractApplicationContext#createEnvironment
*/
public interface Environment extends PropertyResolver {
/**
-
Return the set of profiles explicitly made active for this environment. Profiles
-
are used for creating logical groupings of bean definitions to be registered
-
conditionally, for example based on deployment environment. Profiles can be
-
activated by setting {@linkplain AbstractEnvironment#ACTIVE_PROFILES_PROPERTY_NAME
-
“spring.profiles.active”} as a system property or by calling
-
{@link ConfigurableEnvironment#setActiveProfiles(String…)}.
-
If no profiles have explicitly been specified as active, then any {@linkplain
-
#getDefaultProfiles() default profiles} will automatically be activated.
-
@see #getDefaultProfiles
-
@see ConfigurableEnvironment#setActiveProfiles
-
@see AbstractEnvironment#ACTIVE_PROFILES_PROPERTY_NAME
*/
String[] getActiveProfiles();
/**
-
Return the set of profiles to be active by default when no active profiles have
-
been set explicitly.
-
@see #getActiveProfiles
-
@see ConfigurableEnvironment#setDefaultProfiles
-
@see AbstractEnvironment#DEFAULT_PROFILES_PROPERTY_NAME
*/
String[] getDefaultProfiles();
/**
-
Return whether one or more of the given profiles is active or, in the case of no
-
explicit active profiles, whether one or more of the given profiles is included in
-
the set of default profiles. If a profile begins with ‘!’ the logic is inverted,
-
i.e. the method will return true if the given profile is not active.
-
For example,
env.acceptsProfiles(“p1”, “!p2”)
will -
return {@code true} if profile ‘p1’ is active or ‘p2’ is not active.
-
@throws IllegalArgumentException if called with zero arguments
-
or if any profile is {@code null}, empty or whitespace-only
-
@see #getActiveProfiles
-
@see #getDefaultProfiles
*/
boolean acceptsProfiles(String… profiles);
}
鉴于注释太多,抽出其中核心代码:
package org.springframework.core.env;
public interface Environment extends PropertyResolver {
String[] getActiveProfiles();
String[] getDefaultProfiles();
boolean acceptsProfiles(String… profiles);
}
可以看到Environment 又extends PropertyResolver
/*
-
Copyright 2002-2013 the original author or authors.
-
Licensed under the Apache License, Version 2.0 (the “License”);
-
you may not use this file except in compliance with the License.
-
You may obtain a copy of the License at
自我介绍一下,小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数Java工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但对于培训机构动则几千的学费,着实压力不小。自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Java开发全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,基本涵盖了95%以上Java开发知识点,真正体系化!
由于文件比较大,这里只是将部分目录大纲截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频,并且后续会持续更新
如果你觉得这些内容对你有帮助,可以添加V:vip1024b 备注Java获取(资料价值较高,非无偿)
Java高频面试专题合集解析:
当然在这还有更多整理总结的Java进阶学习笔记和面试题未展示,其中囊括了Dubbo、Redis、Netty、zookeeper、Spring cloud、分布式、高并发等架构资料和完整的Java架构学习进阶导图!
更多Java架构进阶资料展示
zNhMm-1711579126273)]
当然在这还有更多整理总结的Java进阶学习笔记和面试题未展示,其中囊括了Dubbo、Redis、Netty、zookeeper、Spring cloud、分布式、高并发等架构资料和完整的Java架构学习进阶导图!
[外链图片转存中…(img-FSn3zuXw-1711579126274)]
更多Java架构进阶资料展示
[外链图片转存中…(img-jGj5eJFi-1711579126274)]
[外链图片转存中…(img-ZavRZNND-1711579126275)]
[外链图片转存中…(img-LIyeBDpf-1711579126275)]