我想在Spring Boot JPA MVC Web应用程序中填充一些初始/样本记录。在Grails中,我看到了一个示例,其中grails-app/init/BootStrap
文件在init
封闭中进行了初始化。
如何在Spring Boot Web应用程序中执行相同操作?
答案 0 :(得分:0)
您可以使用以下代码:
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;
@Component
public class Bootstrap implements InitializingBean {
@Override
public void afterPropertiesSet() throws Exception {
// YOUR CODE...
}
}