Home > Article > Web Front-end > Spring configuration
This time I will bring you Spring configuration. What are the precautions for Spring configuration? The following is a practical case, let’s take a look.
Configuration fileName: applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <!-- Spring整合Hibernate --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation" value="classpath:hibernate.cfg.xml"> </property> </bean> <bean id="userDao" class="com.troyforever.example.mvc.dao.UserImpl"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <!-- 分页 --> <bean id="pageDao" class="com.troyforever.example.mvc.dao.PageDao"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean id="contactDao" class="com.troyforever.example.mvc.dao.ContactImpl"> <property name="sessionFactory" ref="sessionFactory"></property> <property name="pageDao" ref="pageDao"></property> </bean></beans>
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to the php Chinese websiteOthersrelated articles!
Related reading:
The above is the detailed content of Spring configuration. For more information, please follow other related articles on the PHP Chinese website!