element.
]]>
and other elements, typically the root element in the document.
Allows the definition of default values for all nested bean definitions. May itself
be nested for the purpose of defining a subset of beans with certain default values or
to be registered only when certain profile(s) are active. Any such nested element
must be declared as the last element in the document.
]]>
element should be parsed. Multiple profiles
can be separated by spaces, commas, or semi-colons.
If one or more of the specified profiles are active at time of parsing, the
element will be parsed, and all of its elements registered, <import>
elements followed, etc. If none of the specified profiles are active at time of
parsing, then the entire element and its contents will be ignored.
If a profile is prefixed with the NOT operator '!', e.g.
indicates that the element should be parsed if profile "p1" is active or
if profile "p2" is not active.
Profiles are activated in one of two ways:
Programmatic:
ConfigurableEnvironment#setActiveProfiles(String...)
ConfigurableEnvironment#setDefaultProfiles(String...)
Properties (typically through -D system properties, environment variables, or
servlet context init params):
spring.profiles.active=p1,p2
spring.profiles.default=p1,p2
]]>
element (or "ref"
attribute). We recommend this in most cases as it makes documentation
more explicit.
Note that this default mode also allows for annotation-driven autowiring,
if activated. "no" refers to externally driven autowiring only, not
affecting any autowiring demands that the bean class itself expresses.
2. "byName"
Autowiring by property name. If a bean of class Cat exposes a "dog"
property, Spring will try to set this to the value of the bean "dog"
in the current container. If there is no matching bean by name, nothing
special happens.
3. "byType"
Autowiring if there is exactly one bean of the property type in the
container. If there is more than one, a fatal error is raised, and
you cannot use byType autowiring for that bean. If there is none,
nothing special happens.
4. "constructor"
Analogous to "byType" for constructor arguments. If there is not exactly
one bean of the constructor argument type in the bean factory, a fatal
error is raised.
Note that explicit dependencies, i.e. "property" and "constructor-arg"
elements, always override autowiring.
Note: This attribute will not be inherited by child bean definitions.
Hence, it needs to be specified per concrete bean definition. It can be
shared through the 'default-autowire' attribute at the 'beans' level
and potentially inherited from outer 'beans' defaults in case of nested
'beans' sections (e.g. with different profiles).
]]>
" element.
]]>
..." element.
]]>
".
]]>
..." element.
]]>
".
]]>
..."
element.
]]>
".
]]>
..." element.
]]>