<? XML version = "1.0" encoding = "UTF-8" ?>
< Beans
Xmlns = "Http://www.springframework.org/schema/beans"
Xmlns: xsi = "Http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemalocation = "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd" >
< Bean ID = "Database"
Class = "Org. Apache. commons. DBCP. basicdatasource" >
< Property Name = "Driverclassname"
Value = "Com. MySQL. JDBC. Driver" >
</ Property >
< Property Name = "Url"
Value = "JDBC: mysql: // localhost: 3306/test? Characterencoding = GBK" >
</ Property >
< Property Name = "Username" Value = "Root" > </ Property >
< Property Name = "Password" Value = "Sa" > </ Property >
</ Bean >
< Bean ID = "Sessionfactory"
Class = "Org. springframework. Orm. hibernate3.localsessionfactorybean" >
< Property Name = "Datasource" >
< Ref Bean = "Database" />
</ Property >
< Property Name = "Hibernateproperties" >
< Props >
< Prop Key = "Hibernate. dialect" >
Org. hibernate. dialect. mysqldialect
</ Prop >
< Prop Key = "Hibernate. show_ SQL" >
True
</ Prop >
</ Props >
</ Property >
< Property Name = "Mappingresources" >
< List >
< Value > COM/model/login. HBM. xml </ Value >
< Value > COM/model/U. HBM. xml </ Value >
</ List >
</ Property >
</ Bean >
< Bean ID = "Userdao" Class = "Com. Dao. userdao" >
< Property Name = "Sessionfactory" >
< Ref Bean = "Sessionfactory" > </ Ref >
</ Property >
</ Bean >
< Bean ID = "Userbo" Class = "Com. Bo. userbo" >
< Property Name = "Userdao" >
< Ref Bean = "Userdao" > </ Ref >
</ Property >
</ Bean >
< Bean Name = "/Register" Class = "Com. Action. registeraction" >
< Property Name = "Userbo" >
< Ref Bean = "Userbo" > </ Ref >
</ Property >
</ Bean >
</ Beans >
Database Operations
Public static void main (string [] ARGs) {
applicationcontext context = new filesystemxmlapplicationcontext ("webroot/WEB-INF/spring-config.xml ");
iuserbo userbo = (iuserbo) context. getbean ("userbo");
login Login = New Login ();
login. setusername ("Zhong");
login. setpassword ("5");
userbo. saveuserinfo (LOGIN);
}