9

ShedLock报错: Factory method 'proxyScheduledLockAopBeanPostProcessor' threw exc...

 2 years ago
source link: https://www.oschina.net/question/1763477_2324646
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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

ducat7 发布于 12/08 10:38

这个错怎样修复???
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");
	}
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK