@Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { auth .inMemoryAuthentication() .withUser("admin").password("password").roles("ADMIN"); } @Override protected void configure(HttpSecurity http) throws Exception { http .authorizeRequests() .antMatchers("/jobrunr/**").hasRole("ADMIN") .anyRequest().authenticated() .and() .httpBasic(); } } JobScheduler jobScheduler = new JobScheduler( new BackgroundJobServer( configuration, new ContainerJobZooKeeper(backgroundJobServerConfiguration), backgroundJobServerConfiguration)); BackgroundJob.<MyJob>enqueue(() -> { }); public class MyJob { public void perform() { try { } catch (Exception e) { JobContext.BackgroundJob .getJob() .getJobDetails() .setFailedAt(ZonedDateTime.now()); } } }


上一篇:
下一篇:
切换中文