ShedLock报错: Factory method 'proxyScheduledLockAopBeanPostProcessor' threw exception???

ducat7 发布于 2021/12/08 10:38
阅读 507
收藏 0

这个错怎样修复???
Factory method 'proxyScheduledLockAopBeanPostProcessor' threw exception; nested exception is java.lang.NoSuchMethodError

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [net.javacrumbs.shedlock.spring.aop.MethodProxyScheduledLockAdvisor]: Factory method 'proxyScheduledLockAopBeanPostProcessor' threw exception; nested exception is java.lang.NoSuchMethodError: org.springframework.aop.support.annotation.AnnotationMatchingPointcut.<init>(Ljava/lang/Class;Ljava/lang/Class;Z)V
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
	... 78 more
Caused by: java.lang.NoSuchMethodError: org.springframework.aop.support.annotation.AnnotationMatchingPointcut.<init>(Ljava/lang/Class;Ljava/lang/Class;Z)V
	at net.javacrumbs.shedlock.spring.aop.MethodProxyScheduledLockAdvisor.methodPointcutFor(MethodProxyScheduledLockAdvisor.java:47)
	at net.javacrumbs.shedlock.spring.aop.MethodProxyScheduledLockAdvisor.<init>(MethodProxyScheduledLockAdvisor.java:36)
	at net.javacrumbs.shedlock.spring.aop.MethodProxyLockConfiguration.proxyScheduledLockAopBeanPostProcessor(MethodProxyLockConfiguration.java:36)
	at net.javacrumbs.shedlock.spring.aop.MethodProxyLockConfiguration$$EnhancerBySpringCGLIB$$538e96b6.CGLIB$proxyScheduledLockAopBeanPostProcessor$0(<generated>)
	at net.javacrumbs.shedlock.spring.aop.MethodProxyLockConfiguration$$EnhancerBySpringCGLIB$$538e96b6$$FastClassBySpringCGLIB$$98444f76.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
	at net.javacrumbs.shedlock.spring.aop.MethodProxyLockConfiguration$$EnhancerBySpringCGLIB$$538e96b6.proxyScheduledLockAopBeanPostProcessor(<generated>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
	... 79 more

1、build.gradle:

    compile "net.javacrumbs.shedlock:shedlock-spring:4.29.0"
    compile "net.javacrumbs.shedlock:shedlock-provider-redis-spring-1:4.29.0"

2、配置类:

import net.javacrumbs.shedlock.core.LockProvider;
import net.javacrumbs.shedlock.provider.redis.spring1.RedisLockProvider;
import net.javacrumbs.shedlock.spring.annotation.EnableSchedulerLock;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;

@EnableSchedulerLock(defaultLockAtMostFor = "10m")
@Configuration
public class ShedLockConfig {
	@Bean
	public LockProvider lockProvider(RedisConnectionFactory connectionFactory) {
		return new RedisLockProvider(connectionFactory);
	}
}

3、任务类:

import net.javacrumbs.shedlock.spring.annotation.SchedulerLock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
public class TimerTask {
	private static final Logger logger = LoggerFactory.getLogger(TimerTask.class);

	@Autowired
	private QuantumSecurity quantumSecurity;

	@SchedulerLock(name = "quantum_refresh"
			, lockAtLeastFor = "5m"
	)
	@Scheduled(cron = "0 0 1 * * ?")
	public void refresh() {
		logger.info("quantum refresh");
	}
}

 

加载中
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部