JavaWeb项目调整为gradle项目并解决报错.apache.commons.collections.CollectionUtils.isEmpty(Ljava/util/Collection;)

普通JavaWeb项目调整为gradle项目结构

1、选中项目--configure-convert to Gradle project

2、按gradle项目标准调整代码路径

3、新增gradle配置文件

4、gradle-refresh dependencies 

 

并且在启动项目时有报错如下:

关键字:org.apache.commons.collections.CollectionUtils.isEmpty(Ljava/util/Collection;)Z

原因:commons.collections-3.1.jar包缺失方法。

解决办法:升级为commons.collections-3.2.2.jar

验证通过

三月 30, 2020 8:42:46 上午 org.apache.catalina.core.StandardContext listenerStart
严重: Exception sending context initialized event to listener instance of class com.framework.web.mvc.core.SpringContextListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redis.operation.ctgRedisClient' defined in class path resource [redis-config/redis.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.redis.CtgRedisClient]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.apache.commons.collections.CollectionUtils.isEmpty(Ljava/util/Collection;)Z
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:285)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:993)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:897)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:563)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:872)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
	at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
	at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
	at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
	at com.tydic.framework.web.mvc.core.SpringContextListener.contextInitialized(SpringContextListener.java:25)
	at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4939)
	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5434)
	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.tydic.redis.CtgRedisClient]: Constructor threw exception; nested exception is java.lang.NoSuchMethodError: org.apache.commons.collections.CollectionUtils.isEmpty(Ljava/util/Collection;)Z
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:141)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:107)
	at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:277)
	... 24 more
Caused by: java.lang.NoSuchMethodError: org.apache.commons.collections.CollectionUtils.isEmpty(Ljava/util/Collection;)Z
	at com.ctg.itrdc.cache.monitor.MonitorWorkerPool.addMonitorWorker(MonitorWorkerPool.java:95)
	at com.ctg.itrdc.cache.pool.CtgJedisPool.initMonitorWorker(CtgJedisPool.java:57)
	at com.ctg.itrdc.cache.pool.CtgJedisPool.(CtgJedisPool.java:47)
	at com.tydic.redis.CtgRedisClient.(CtgRedisClient.java:90)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
	at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:126)
	... 26 more

 

你可能感兴趣的:(工作心得)