I have the below PROTOTYPE class .
1, Will my DemoService objects destroyed by spring?And will it be garbage collected?
2. How can i manually destroy the DemoService so it is Garbage Collected?
@Service
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE, proxyMode = ScopedProxyMode.TARGET_CLASS)
public class DemoService {
@Autowired
private DaoCall daoCall; //call to database.Connection will be closed by the connection pool.
@Autowired
private KafkaTemplate<String, String> template; //used to send message to Kafka
}
I am injecting DemoService prototype class in the singleton class GreetingController
@RestController
public class GreetingController {
@Autowired
private DemoService demoService;
@GetMapping("/greeting")
public String greeting()
{
demoService. //call to demoService
return "Hello ";
}