java 字符串模板的最佳实践是什么? Apache Commons StrSubstitutor 是可供选择的正确工具吗?

What is the best practice of java string template? Is Apache Commons StrSubstitutor the right tool to choose?

我认为 StrSubstitutor 作为字符串模板的用法在 Java 中非常干净。 但是已经弃用了,还能长期使用吗?

javadocs 说:

"Deprecated as of 1.3, use StringSubstitutor instead. This class will be removed in 2.0."

参考:https://commons.apache.org/proper/commons-text/javadocs/api-release/org/apache/commons/text/StrSubstitutor.html ...并跟随链。

can I still use it for a long time?

在 API 的 2.0 版发布之前您可以使用它1。我们无法预测那会是什么时候。

1 - 理论上你可以使用它 "forever" ...但是如果你使用/升级到依赖的另一个库的某个版本,你可能 运行 陷入依赖冲突在更高版本的 Apache Commons 上。