欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Spring启动报错:java.lang.ClassNotFoundException: org.springframework.expression.ParserContext

程序员文章站 2022-04-14 20:41:52
...

1.记录一次启动报错:

Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/expression/ParserContext
	at org.springframework.context.support.AbstractApplicationContext.prepareBeanFactory(AbstractApplicationContext.java:629)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:517)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
	at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:93)
	at com.gaosi.squirrel.start.Main.start(Main.java:69)
	at com.gaosi.squirrel.start.Main.main(Main.java:48)
Caused by: java.lang.ClassNotFoundException: org.springframework.expression.ParserContext
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
	... 6 more

解决办法:

<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-expression</artifactId>
    <version>【和你所用的Spring版本匹配】</version>
</dependency>

我是在用spring-data-mongodb时exclusion掉了spring-expression:
Spring启动报错:java.lang.ClassNotFoundException: org.springframework.expression.ParserContext
最后,把exclusion掉的spring-expression注释起来,就OK了,同时maven依赖里也有了spring-expression包,最后启动就OK了。