noclassdeffounderror:net/javacrumps/shedlock/core/lockprovider

sshcrbum  于 2021-07-24  发布在  Java
关注(0)|答案(0)|浏览(1223)

我们尝试开发cron批处理。我配置了一个@schedulerlock anotion,但这些都不起作用。此代码可能用于多个节点。我在github中读到,@schedulerlock可以与这些实现一起工作,但不能工作。我也试过了,但也没用。我需要帮助来运行这些代码,因为我不知道代码中的失败是什么。谢谢!

@SpringBootApplication
@EnableAutoConfiguration
@EnableCaching
public class AppExportacionDatos {

    public static void main(String[] args) {
        SpringApplication.run(AppExportacionDatos.class, args);
    }

}
@Configuration
@EnableScheduling
@EnableSchedulerLock(defaultLockAtMostFor = "540m")
public class CommonConfig {

    @Bean
    public LockProvider lockProvider(DataSource dataSource) {
        return new JdbcTemplateLockProvider(
            JdbcTemplateLockProvider.Configuration.builder()
            .withJdbcTemplate(new JdbcTemplate(dataSource))
            .usingDbTime() // Works on Postgres, MySQL, MariaDb, MS SQL, Oracle, DB2, HSQL and H2
            .build()
        );
    }
    @Bean
    public MessageSource messageSource() {
        ReloadableResourceBundleMessageSource messageSource = new ReloadableResourceBundleMessageSource();
        messageSource.setBasename("classpath:i18n/messages");
        messageSource.setDefaultEncoding("ISO-8859-1");
        return messageSource;
    }
    @Bean
    public LocalValidatorFactoryBean getValidator() {
        LocalValidatorFactoryBean bean = new LocalValidatorFactoryBean();
        bean.setValidationMessageSource(messageSource());
        return bean;
    }

}
@Component
public class BatchTasks {

//  @Scheduled(cron = "${cronExpression}")
    @Scheduled(fixedDelay = 60000)
    @SchedulerLock(name = "scheduledTaskName") 
    public void generarFicheroExportacion() {
        ................
    }
}
<dependency>
            <groupId>net.javacrumbs.shedlock</groupId>
            <artifactId>shedlock-spring</artifactId>
            <version>4.20.0</version>
        </dependency>
        <dependency>
            <groupId>net.javacrumbs.shedlock</groupId>
            <artifactId>shedlock-provider-jdbc-template</artifactId>
            <version>4.20.0</version>
        </dependency>

运行应用程序的例外情况是:

Caused by: java.lang.ClassNotFoundException: net.javacrumbs.shedlock.core.LockProvider
    at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[?:1.8.0_281]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[?:1.8.0_281]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) ~[?:1.8.0_281]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_281]
    at java.lang.Class.forName0(Native Method) ~[?:1.8.0_281]
    at java.lang.Class.forName(Class.java:348) ~[?:1.8.0_281]
    at org.springframework.boot.devtools.restart.classloader.RestartClassLoader.loadClass(RestartClassLoader.java:144) ~[spring-boot-devtools-2.4.0.jar:2.4.0]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[?:1.8.0_281]
    at java.lang.Class.getDeclaredMethods0(Native Method) ~[?:1.8.0_281]
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[?:1.8.0_281]
    at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[?:1.8.0_281]
    at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:463) ~[spring-core-5.3.1.jar:5.3.1]
    ... 26 more

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题