Home > Enterprise >  Spring ShedLock without Database
Spring ShedLock without Database

Time:01-11

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

CodePudding user response:

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

  •  Tags:  
  • Related