Home  >  Article  >  Web Front-end  >  Spring configuration

Spring configuration

php中世界最好的语言
php中世界最好的语言Original
2018-03-07 17:00:171159browse

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:

Web.xml configuration

Spring’s MVC configuration

The above is the detailed content of Spring configuration. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:web.xml configurationNext article:web.xml configuration