diff --git a/CHANGELOG.md b/CHANGELOG.md index 485e6801e..4ae3607fa 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,13 @@ # 🚀Changelog ------------------------------------------------------------------------------------------------------------- -# 5.8.16.M1 (2023-03-17) +# 5.8.16.M1 (2023-03-20) ### 🐣新特性 * 【core 】 改进Calculator.conversion,兼容乘法符号省略写法(issue#2964@Github) * 【core 】 改进XmlUtil.xmlToBean,支持xml转bean时父节点忽略大小写 * 【core 】 优化ArrayUtil的空判断(pr#2969@Github) +* 【extra 】 优化SpringUtil在非Spring环境下的异常(issue#2835@Github) ### 🐞Bug修复 * 【crypto】 修复NoSuchMethodError未捕获问题(issue#2966@Github) diff --git a/hutool-extra/src/main/java/cn/hutool/extra/spring/SpringUtil.java b/hutool-extra/src/main/java/cn/hutool/extra/spring/SpringUtil.java index ea08f0921..203888014 100755 --- a/hutool-extra/src/main/java/cn/hutool/extra/spring/SpringUtil.java +++ b/hutool-extra/src/main/java/cn/hutool/extra/spring/SpringUtil.java @@ -71,7 +71,11 @@ public class SpringUtil implements BeanFactoryPostProcessor, ApplicationContextA * @since 5.7.0 */ public static ListableBeanFactory getBeanFactory() { - return null == beanFactory ? applicationContext : beanFactory; + final ListableBeanFactory factory = null == beanFactory ? applicationContext : beanFactory; + if(null == factory){ + throw new UtilException("No ConfigurableListableBeanFactory or ApplicationContext injected, maybe not in the Spring environment?"); + } + return factory; } /**