@RestController
@Slf4j
public class DependencyBeanTest {
@Autowired
@Lazy
private CurrentDate currentDate;
@Autowired
private DependencyBeanService dependencyBeanService;
@PostMapping("/test/getTime")
public String getTime(){
log.info(currentDate.toString());
dependencyBeanService.log();
return dependencyBeanService.getTime();
}
}
@Service
@Scope(value = "request")
public class CurrentDate {
private Date now;
@PostConstruct
private void init(){
now = new Date();
}
public Date now(){
return now;
}
}
@Service
@Slf4j
public class DependencyBeanService {
@Autowired
@Lazy
private com.dffl.oms.order.help.CurrentDate currentDate;
public void log(){
log.info("=============================service==============="+JsonUtil.toJson(currentDate.now()));
}
public String getTime(){
log.info(currentDate.toString());
return JsonUtil.toJson(currentDate.now());
}
}