-
Notifications
You must be signed in to change notification settings - Fork 54.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bael 8370 new: Add Execution Metadata to Scheduled Tasks in Spring Bo…
…ot Actuator (#18103) * #BAEL-8370-New: add Jobs * #BAEL-8370-New: add SecurityConfig * #BAEL-8370-New: update Spring Boot version to 3.4.0 * #BAEL-8370-New: add htmlunit.version to spring-boot-rest module * #BAEL-8370-New: revert Spring Boot version * #BAEL-8370-NEW: revert htmlunit version * #BAEL-8370-NEW: update Spring Boot version to 3.4.0 * #BAEL-8370-New: update Spring Boot version to 3.4.1 * #BAEL-8370-New: replace removed method in htmlunit * #BAEL-8370-New: add dependency version for htmlunit * #BAEL-8370-New: resolve error: com.google.common.util.concurrent.Futures cannot be applied to given types; * #BAEL-8370-New: revert parent Spring Boot 3 * #BAEL-8370-New: revert change due to Spring Boot 3 Update * #BAEL-8370-New: revert change due to Spring Boot 3 Update * #BAEL-8370-New: revert change due to Spring Boot 3 Update * #BAEL-8370-New: add Spring Boot 3 separately * #BAEL-8370-New: update JUnit to 5 --------- Co-authored-by: m_mohammadi <m_mohammadi@modernisc.com>
- Loading branch information
1 parent
bf63962
commit a76b74b
Showing
11 changed files
with
105 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
spring-boot-modules/spring-boot-simple/src/main/java/com/baeldung/actuator/JobConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.baeldung.actuator; | ||
|
||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.scheduling.annotation.EnableScheduling; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
|
||
@Configuration | ||
@EnableScheduling | ||
public class JobConfig { | ||
|
||
@Scheduled(fixedDelay = 1000L) | ||
public void scheduleFixedDelayTask() { | ||
System.out.println("Fixed delay task - " + System.currentTimeMillis() / 1000); | ||
} | ||
|
||
@Scheduled(fixedRate = 1000L) | ||
public void scheduleFixedRateTask() { | ||
System.out.println("Fixed rate task - " + System.currentTimeMillis() / 1000); | ||
} | ||
|
||
@Scheduled(cron = "0 15 10 15 * ?") | ||
public void scheduleTaskUsingCronExpression() { | ||
long now = System.currentTimeMillis() / 1000; | ||
System.out.println("schedule tasks using cron jobs - " + now); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...g-boot-modules/spring-boot-simple/src/main/java/com/baeldung/actuator/SecurityConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package com.baeldung.actuator; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; | ||
import org.springframework.security.web.SecurityFilterChain; | ||
|
||
@Configuration | ||
@EnableWebSecurity | ||
public class SecurityConfig { | ||
|
||
@Bean | ||
public SecurityFilterChain securityWebFilterChain(HttpSecurity http) throws Exception { | ||
return http | ||
.authorizeHttpRequests(auth -> auth | ||
.requestMatchers("/actuator/**").permitAll() | ||
.anyRequest().authenticated()) | ||
.build(); | ||
} | ||
} |
10 changes: 5 additions & 5 deletions
10
...s/spring-boot-simple/src/test/java/com/baeldung/actuator/ActuatorInfoIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...ot-modules/spring-boot-simple/src/test/java/com/baeldung/bootstrap/SpringContextTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
...c/test/java/com/baeldung/configurationproperties/PropertiesConversionIntegrationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters