java开发常见错误分析处理

1、提示 NoSuchMethodError 一般为引用的jar包版本冲突问题,需要重新调整版本

2、提示java.lang.IndexOutOfBoundsException 导致tomcat无法启动,一般是maven的depedency出现错了冲突,需要发现并重新调整

3、加载resources文件下的配置文件时,提示Could not resolve placeholder,不是找不到,而是无法加载问题,一般是加载多个文件出现的,需要在后面添加ignore-unresolvable="true   如:<context:property-placeholder location="classpath:db.properties" ignore-unresolvable="true" />

4、BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext

application.xml文件有问题或者pom.xml存在问题

5、加载文件时用*符号,表示加载所有classpath下面的xml文件,这就造成了一种情况,就是在junit时候能加载spring自动注入,而使用tomcat却加载不了,同时还不会报错,所以配置文件路径时,不要加*   如:<context:property-placeholder location="classpath*:db.properties" ignore-unresolvable="true" />

6、提示java.lang.NoClassDefFoundError:redis/clients/jedis/GeoUnit  表示jedis包的版本有问题,没有这个方法,需要换成高版本

7、提示Error creating bean with name 'redisCacheUtil': Injection of autowired dependencies failed,则改用resource加载

8、maven项目,如果提示找不到某些方法,但是这些方法又有,那么需要在Properties-----DeploymentAssembly中把maven dependency 加入到lib下


猜你喜欢

转载自blog.csdn.net/u013816904/article/details/80393372