Spring에서 명시적에서 암시적 구성으로의 변환

Before (명시적 bean 정의)
@Configuration
public class AppConfig {

    @Bean
    public AppService appService() {
        return new AppServiceImpl(appRepository());
    }

    @Bean
    public AppRepository appRepository() {
        ...
    }
}
이후(암시적 구성)
@Configuration
@ComponentScan("com.services")
public class AppConfig {
}

@Component
public class AppServiceImpl implements AppService {
    @Autowired
    public AppServiceImpl(AppRepository appRepository) {
        this.appRepository = appRepository;
    }
}

좋은 웹페이지 즐겨찾기