BeanFactory not initialized or already closed

来源:互联网 发布:大数据量 数据库 编辑:程序博客网 时间:2024/06/07 10:40

BeanFactory not initialized or already closed - call ‘refresh’ before accessing beans via the ApplicationContext

jboss启动报错,百度结果如下:

错误:java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext错误原因:BeanFactory没有实例化或者已经关闭。原因很简单:ApplicationContext ctx = new ClassPathXmlApplicationContext();Spring实例化BeanFactory的时候是默认到classPath下面查找名为applicationContext.xml的文件。这正是这个错误的原因,修改为:ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");如果这样的话就不会出现这样的错误了。applicationContext.xml,可以是自己命名的xml

然后并不符合我本地的情况,检查代码发现出现了相同的注解名称(我是复制过来的service然后改的,忽略了service的注解名忘记改了)

@Service("loginservice")public class UserService {}

将loginservice改成userservice,ok

注意养成良好的编码习惯,否则总是会出现一些莫名其妙的报错信息,然后照着百度又会改的面目全非,哈哈

1 0
原创粉丝点击