Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- 단축키
- 줄바꿈 문자
- port
- context
- maVen
- JavaScript
- 네트워크
- profile
- find
- netsh
- Windows
- Quartz
- Windows 10
- grep
- resource
- IntelliJ
- VirtualBox
- bash
- Eclipse
- import
- lsof
- vscode
- GIT
- Source
- ssh
- plugin
- web.xml
- Mac
- xargs
- tomcat
Archives
- Today
- Total
develog
[spring boot] 초기화 코드 본문
- PostConstruct
@Component
@RequiredArgsConstructor
public class InitDB {
private final InitService initService;
@PostConstruct
public void init() {
initService.dbInit1();
}
}
@Component
@RequiredArgsConstructor
public class InitDb {
private final ItemRepository itemRepository;
@PostConstruct
public void init() {
itemRepository.save(new Item("item1", 1000, 10));
itemRepository.save(new Item("item2", 2000, 20));
itemRepository.save(new Item("item3", 3000, 30));
}
}
- CommandLineRunner
@Component
@RequiredArgsConstructor
public class InitDB {
private final InitService initService;
@Bean
public CommandLineRunner commandLineRunner(ApplicationContext ctx) {
return args -> {
initService.dbInit1();
};
}
}
- CommandLineRunner
@Component
public class MyRunner implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
System.out.println("~~~~~~~~~~~~~~~~ MyRunner.run");
}
}
'Dev > Spring Boot' 카테고리의 다른 글
[spring boot] Hibernate5Module (0) | 2020.11.02 |
---|---|
[spring boot] static 폴더 파일 읽기 (0) | 2020.11.02 |
[spring boot 2.3] javax.validation dependency (0) | 2020.10.25 |
[spring boot] multiple properties file (0) | 2020.08.12 |
Spring Boot jar, docker build (0) | 2020.08.06 |
Comments