我在spring boot应用中有以下代码:
@ApplicationScope
@Component
@Slf4j
public class ApplicationLists {
private List<Country> countryItems = new ArrayList<Country>();
@PostConstruct
protected void init() {
initCountryList();
@PostConstruct 方法只有在我通过邮递员提交请求时才会调用,我需要 此代码运行 om 启动。 谢谢,
答案 0 :(得分:0)
我正在实现 ApplicationRunner 而不是 @PostConstruct,它有 运行方法。这就是解决问题,我只是希望 这是 Spring Boot 中正确的做法。