스프링
-
스프링 Properties 관련 정리SPRING 2020. 4. 15. 14:24
프로퍼티 - 다양한 방법으로 정의할 수 있는 설정 값 - Environment는 properties source 설정과 properties value를 가져오는 역할을 한다. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 package com.example.demo; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.PropertySource; @SpringBootApplication @PropertySource("classpath:/ap..
-
DI 주입 방법(3가지)SPRING 2020. 3. 23. 22:34
1. 생성자를 이용한 의존성 주입 방법 (스프링 버전 4.3이상에서는 생성자를 이용한 Bean 주입시 @Autowired 생략 가능) -> 스프링 공식 문서에서 가장 추천하는 방식임. 1 2 3 4 5 public OwnerController(OwnerRepository clinicService, VisitRepository visits) { this.owners = clinicService; this.visits = visits; } http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter 2. 필드에서 의존성 주입 방법 -> 실무에서는 보통 이러한 방..