Recently, the general business system framework is still being integrated, and the required configurations are loaded using plug-ins. The spring and struts2 configurations have been dynamically loaded, currently, the rest of the Hibernate ing file is not dynamically loaded yet, so the source code for data search is finally implemented. 1. Override the SessionFactory class to create a class that inherits org. springframework. orm. hibernate3.LocalSessionFactoryBean, rewrite newSessionFactory (Configuration config), and call config in this method. addFile () method adds hbm files to be dynamically loaded. Main Code: [java] public class ShineSessionFactoryBean extends LocalSessionFactoryBean {@ Override protected SessionFactory newSessionFactory (Configuration config) throws HibernateException {config. addFile ("xx1.hbm. xml "); // The hbm configuration to be added here All files are loaded into config. addFile ("xx2.hbm. xml "); return super. newSessionFactory (config);} 2. Modify the Spring configuration file to change the original org. springframework. orm. change hibernate3.LocalSessionFactoryBean to the rewritten class, remove the hbm path configured here, or retain it, but do not duplicate it with the hbm file injected by the plug-in. Other attributes are the same. [Html] <bean id = "sessionFactory" class = "com. shine. spring. ShineSessionFactoryBean"> <property name = "dataSource" ref = "dataSource"/> <! -- The hbm file has been changed to <property name = "mappingLocations"> <list> <value> classpath *: com/shine/**/entity/hbm /*. hbm. xml </value> </list> </property> --> </bean> takes effect after restart. You must pay attention to the following issues during integration: 1. If newSessionFactory obtains the hbm file to be loaded from the global variables of the system, you must set the value for the global variable before the spring container initialization. 2. Dynamically Loaded hbm. make sure that the file path exists in the xml file. If the configuration file to be loaded is in the jar package or is not on the local machine, you must read the configuration file and encapsulate it. 3. If the system requires multiple SessionFactory instances, you must load different hbm configuration files for different SessionFactory instances (I add the ID attribute for SessionFactory ).