` This is callback1 class, has String1 as setter dependency. I’m setting this manually by taking it from ApplicationContext and calling hashcode on the object in afterPropertiesSet()
package com.example.springcore;
import jakarta.annotation.PostConstruct;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
@Component
public class callback1 implements InitializingBean, DisposableBean {
//@Autowired
private String1 string;
@Autowired
private ApplicationContext applicationContext;
@Override
public void destroy() throws Exception {
System.out.println("I'm going to destroyed");
System.out.println(string.hashCode());
}
@Override
public void afterPropertiesSet() throws Exception {
System.out.println("I'm after properties set----");
// System.out.println("afterPropertiesSet() "+string.hashCode());
System.out.println("afterPropertiesSet() "+applicationContext.hashCode());
this.string = applicationContext.getBean(String1.class);
System.out.println("afterPropertiesSet() "+string.hashCode());
}
@PostConstruct
public void afterPropertiesSet1() throws Exception {
System.out.println("I'm after @postconstruct set----");
System.out.println("postconstruct() "+string.hashCode());
}
}
`