2024年1月26日发(作者:)
1 /** 2 * Abstract base class for property resource configurers that resolve placeholders 3 * in bean definition property values. Implementations pull values from a 4 * properties file or other {@linkplain tySource 5 * property source} into bean definitions. 6 * 7 *
The default placeholder syntax follows the Ant / Log4J / JSP EL style: 8 * 9 *
${...}10 *11 * Example XML bean definition:12 *13 *
14 *19 *20 * Example properties file:21 *22 *15 * 16 * 17 * 18 *
driver=23 * dbname=mysql:mydb24 *25 * Annotated bean definitions may take advantage of property replacement using26 * the {@link @Value} annotation:27 *28 *
@Value("${}")29 *30 * Implementations check simple property values, lists, maps, props, and bean names31 * in bean references. Furthermore, placeholder values can also cross-reference32 * other placeholders, like:33 *34 *
rootPath=myrootdir35 * subPath=${rootPath}/subdir36 *37 * In contrast to {@link PropertyOverrideConfigurer}, subclasses of this type allow38 * filling in of explicit placeholders in bean definitions.39 *40 *
If a configurer cannot resolve a placeholder, a {@link BeanDefinitionStoreException}41 * will be thrown. If you want to check against multiple properties files, specify multiple42 * resources via the {@link #setLocations locations} property. You can also define multiple43 * configurers, each with its own placeholder syntax. Use {@link44 * #ignoreUnresolvablePlaceholders} to intentionally suppress throwing an exception if a45 * placeholder cannot be resolved.46 *47 *
Default property values can be defined globally for each configurer instance48 * via the {@link #setProperties properties} property, or on a property-by-property basis49 * using the default value separator which is {@code ":"} by default and50 * customizable via {@link #setValueSeparator(String)}.51 *52 *
Example XML property with default value:53 *54 *
55 *57 *58 * @author Chris Beams59 * @author Juergen Hoeller60 * @since 3.161 * @see PropertyPlaceholderConfigurer62 * @see tySourcesPlaceholderConfigurer63 */64 public abstract class PlaceholderConfigurerSupport extends PropertyResourceConfigurer65 implements BeanNameAware, BeanFactoryAware {6656 *
67 /** Default placeholder prefix: {@value} */68 public static final String DEFAULT_PLACEHOLDER_PREFIX = "${";69
70 /** Default placeholder suffix: {@value} */71 public static final String DEFAULT_PLACEHOLDER_SUFFIX = "}";72
73 /** Default value separator: {@value} */74 public static final String DEFAULT_VALUE_SEPARATOR = ":";75
76
77 /** Defaults to {@value #DEFAULT_PLACEHOLDER_PREFIX} */78 protected String placeholderPrefix = DEFAULT_PLACEHOLDER_PREFIX;79
80 /** Defaults to {@value #DEFAULT_PLACEHOLDER_SUFFIX} */81 protected String placeholderSuffix = DEFAULT_PLACEHOLDER_SUFFIX;82
83 /** Defaults to {@value #DEFAULT_VALUE_SEPARATOR} */84 @Nullable
本文发布于:2024-01-26 03:46:29,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/1706211989681.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |