package com.example.demo.wstrzykiwanie;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class Inject1 {
	{ System.out.println("Inject1 init"); } // initialization block
	
	// 1. sposób wstrzykiwania: pole
	@Autowired
	private Komponent komponent;

	@Autowired
	private Repo repo;
	
	@RequestMapping("/inject1")
	@ResponseBody
	public String get() {
		return repo.getText() + " " + komponent.getValue();
	}

}
