During development, after number of class increased, it take over 2 minutes until application is started.I think it makes our develop efficiency low...
And I found that if we add 'lazyInit=true', If I add this option, most of classes will be loaded lazily, but repositories are loaded even if I add this option.
@ComponentScan(basePackageClasses = LazyApplication.class,lazyInit=true)
@EnableAutoConfiguration(
)
public class LazyApplication {
public static void main(String[] args) {
SpringApplication.run(LazyApplication.class, args);
}
}
Actually, our system have more than 300 repository and entity, so I want to make repository lazy too if possible.
How can I make my repository will Not be loaded when I start application but loaded when I access to the repository for the first time?
You can use
@Order
annotation on your configuration classes to define load ordering.The highest precedence advice runs first. The lower the number, the higher the precedence. e.g