1번

public class TestController {

	@Autowired
	private Repository repository;
    
}

 

-------------------------------

2번 - lombok 라이브러리

@RequiredArgsConstructor
public class TestController {

	private final Repository repository;
    
}

 

 

--------------------------------

3번 - 컨트롤러 생성자에 DI할 것 넣기

public class TestController{
	
	private final Repository repository;

	public class TestController(Repository repository){
    
		this.repository = repository;
        
    }
}

 

+ Recent posts