Applicationcontext.xml Configuration

Source: Internet
Author: User

The following is a detailed description of spring's Applicationcontext.xml file code: <!--header file, mainly note the code--<?xml version= "1.0" encoding= "UTF-8"?> < ! DOCTYPE beans Public "-//spring//dtd bean//en" "Http://www.springframework.org/dtd/spring-beans.dtd" > <beans > <!--set up data sources--<bean id= "DataSource" class= "Org.apache.commons.dbcp.BasicDataSource" > <!--database driver,    I'm using MySQL database---<property name= "Driverclassname" > <value>com.mysql.jdbc.Driver</value> </property> <!--database address, here also pay attention to coding, otherwise garbled but very depressed oh! --<property name= "url" > <value> jdbc:mysql://localhost:3306/tie?hao947=true&characteren Coding=utf-8 </value> </property> <!--database Username--<property name= "username" > <val Ue>root</value> </property> <!--database Password--<property name= "password" > <value&gt ;123</value> </property> </bean> <!--inject data sources to session factory--<bean id= "SessioNfactory "class=" Org.springframework.orm.hibernate3.LocalSessionFactoryBean "> <property name=" DataSource " > <ref bean= "DataSource"/> </property> <!--configuration Map file--<property name= "MAPPINGRESOURC  Es "> <list> <value>com/hao947/vo/User.hbm.xml</value> </list> </property> </bean> <!--inject the session factory to Hibernatetemplate--and <!-- Explain that Hibernatetemplate:hibernatetemplate provides a number of convenient ways to automatically build Hibernatecallback objects at execution time, such as load (), get (), save, Delete (), and so on. --<bean id= "hibernatetemplate" class= "Org.springframework.orm.hibernate3.HibernateTemplate" > < constructor-arg> <ref local= "sessionfactory"/> </constructor-arg> </bean> <!--inject DAO to Sess Ion Factory--<bean id= "Userdao" class= "Com.hao947.dao.UserDAO" > <property name= "sessionfactory" > <re F bean= "Sessionfactory"/> </property> </bean> <!--inject service to DAO--and &LT; Bean id= "UserService" class= "Com.hao947.service.UserService" > <property name= "Userdao" > <ref local= "us Erdao "/> </property> </bean> <!--inject action to service--<bean name="/user "class=" com.hao947.s Truts.action.UserAction "> <property name=" userservice "> <ref bean=" userservice "/> </property& Gt </bean> </beans>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.