Skip to content

Commit f153f02

Browse files
Merge pull request #16 from brunoalvesrocha/master
Using CommandLineRunner interface springBoot instead @PostConstruct
2 parents aa52921 + 8ca4459 commit f153f02

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/main/java/br/com/concrete/mock/configuration/api/v1/controller/CaptureStateController.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
import org.slf4j.LoggerFactory;
77
import org.springframework.beans.factory.annotation.Autowired;
88
import org.springframework.beans.factory.annotation.Value;
9+
import org.springframework.boot.CommandLineRunner;
10+
import org.springframework.context.annotation.Bean;
911
import org.springframework.http.HttpStatus;
1012
import org.springframework.http.ResponseEntity;
1113
import org.springframework.web.bind.annotation.*;
1214

13-
import javax.annotation.PostConstruct;
14-
1515
@RestController
1616
@RequestMapping("/configuration/capture-state")
1717
public class CaptureStateController {
@@ -28,13 +28,14 @@ public CaptureStateController(CaptureStateService service) {
2828
this.service = service;
2929
}
3030

31-
@PostConstruct
32-
public void init (){
33-
34-
LOGGER.info("Application capture state: " + captureState);
35-
if(captureState){
36-
this.service.enable();
37-
}
31+
@Bean
32+
private CommandLineRunner onLoad() {
33+
return args -> {
34+
LOGGER.info("Application capture state: " + captureState);
35+
if(captureState) {
36+
this.service.enable();
37+
}
38+
};
3839
}
3940

4041
@RequestMapping(method = RequestMethod.GET)

0 commit comments

Comments
 (0)