-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathSpringConfig.java
More file actions
29 lines (24 loc) · 975 Bytes
/
SpringConfig.java
File metadata and controls
29 lines (24 loc) · 975 Bytes
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
package hello.hellospring;
import hello.hellospring.domain.Customer;
import hello.hellospring.repository.*;
import hello.hellospring.service.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class SpringConfig {
private final ProductRepository productRepository;
private final CustomerRepository customerRepository;
public SpringConfig(ProductRepository productRepository, CustomerRepository customerRepository) {
this.customerRepository = customerRepository;
this.productRepository = productRepository;
}
//인터페이스만 만들면 스프링이 구현체를 만들어 bean에
@Bean
public ProductService productService() {
return new ProductService(productRepository);
}
@Bean
public CustomerService customerService() {
return new CustomerService(customerRepository);
}
}