Home >Java >javaTutorial >How to solve springboot jpa lazy loading problem
In springboot, the new spring.jpa.open-in-view=true method in the configuration file of application.properties fails
1. Add
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true;
to the configuration file of application.properties. 2. Add the @Transactional annotation to the test method.
Lazy loading or lazy loading means that when the spring container starts, it does not load all the beans into the spring container, but when needed time, this object is instantiated into the container.
Shorten startup time
If a configuration error occurs, it will not be found when the system starts, and strict testing is required, and It is necessary to ensure that the heap space of the JVM can satisfy all beans
Lazy loading is divided into global lazy loading and local lazy loading. Global lazy loading is achieved through configuration, and local lazy loading is achieved by adding @Lazy annotation to the class
The above is the detailed content of How to solve springboot jpa lazy loading problem. For more information, please follow other related articles on the PHP Chinese website!