java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' befo

博客讨论了在启动Spring应用时遇到的'BeanFactory not initialized'异常,问题源于applicationContext.xml配置文件未找到。解决方案包括在web.xml中调整配置以及检查@Service注解的使用,特别是@ServiceImpl类需添加@Transactional注解以确保事务管理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [applicationContext.xml]; nested exception is java.io.FileNotFoundException: class path resource [applicationContext.xml] cannot be opened because it does not exist

java.lang.IllegalStateException: BeanFactory not initialized or already closed - call ‘refresh’ before accessing beans via the ApplicationContext
翻译
org.springframework.beans.factory.BeanDefinitionStoreException:IOException从类路径资源[applicationContext.xml]解析XML文档; 嵌套异常是java.io.FileNotFoundException:无法打开类路径资源[applicationContext.xml],因为它不存在

java.lang.IllegalStateException:BeanFactory未初始化或已经关闭 - 在通过ApplicationContext访问bean之前调用’refresh’

网上查了是这个配置问题
classpath:applicationContext.xml

只需要在web.xml中修改如下图所示配置就可以正常启动了

在这里插入图片描述Unable to instantiate Action, userAction, defined for ‘user_regist’ in namespace '/‘Error creating bean with name ‘userAction’ defined in URL [file:/D:/apache-tomcat-7.0.52/webapps/sshday/WEB-INF/classes/applicationContext.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.ids.web.action.UserAction]: Constructor threw exception; nested exception is java.lang.Error: Unresolved compilation problem:
The type java.util.Map$Entry cannot be resolved. It is indirectly referenced from required .class files
翻译
无法实例化在命名空间’/'中为’user_regist’定义的Action,userAction错误创建在URL中定义名为’userAction’的bean [file:/ D:/apache-tomcat-7.0.52/webapps/sshday/WEB-INF /classes/applicationContext.xml]:bean的实例化失败; 嵌套异常是org.springframework.beans.BeanInstantiationException:无法实例化[com.ids.web.action.UserAction]:构造函数抛出异常; 嵌套异常是java.lang.Error:未解决的编译问题:
java.util.Map $ Entry类型无法解析。 它是从所需的.class文件间接引用的

是因为serviceimpl业务层,没有添加注解 @Transactional 添加后就可以正常访问了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值