3

I want to disable ShedLock with a configuration yml property. So i don't have to create the table shedlock, if it is not necessary. Is there a way to disable Shedlock usage?

I tried to remove @Bean lockProvider but then I got this message:

No qualifying bean of type 'net.javacrumbs.shedlock.core.LockProvider

CodeSun
  • 206
  • 2
  • 12

1 Answers1

4

If you are using ShedLock in combination with the shedlock-spring dependency, there probably is a @EnableSchedulerLock somewhere in your application. Move the LockProvider bean setup together with the annotation to a separate @Configuration class and add a @ConditionalOnProperty annotation, for example:

@Configuration
@EnableSchedulerLock
@ConditionalOnProperty(value = "shedlock.enabled", matchIfMissing = true)
public class ShedLockConfig {

    @Bean
    public LockProvider lockProvider(DataSource dataSource) {
        // ...
    }
}

And add the property

shedlock:
  enabled: true

To your application.yml

Michiel
  • 2,914
  • 1
  • 18
  • 27