Applicationcontext.xml File Configuration Template

Source: Internet
Author: User

<?xml version= "1.0" encoding= "gb2312"?>
<!--the DTD definition for spring configuration file--
<! DOCTYPE beans Public "-//spring//dtd bean//en"
"Http://www.springframework.org/dtd/spring-beans.dtd" >
<!--the root element of the spring configuration file is beans-->
<beans>
<!--define the data source, the Bean's ID is datasource-->
<bean id= "DataSource" class= "Org.springframework.jdbc.datasource.DriverManagerDataSource" >
<!--specified database driver
<property name= "Driverclassname" ><value>com.mysql.jdbc.Driver</value></property>
<!--specify url--> to connect to the database
<property name= "url" ><value>jdbc:mysql://wonder:3306/j2ee</value></property>
<!--root is the user name of the database--
<property name= "username" ><value>root</value></property>
<!--Pass is a database password--
<property name= "Password" ><value>pass</value></property>
</bean>

<!--define Hibernate's sessionfactory-->
<bean id= "Sessionfactory" class= "Org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
<!--relies on injected data sources to inject exactly the datasource--> defined above
<property name= "DataSource" ><ref local= "DataSource"/></property>
<!--The Mappingresouces property is used to list all mapping files >
<property name= "Mappingresources" >
<list>
<!--the following to list all PO mapping files--
<value>lee/Person.hbm.xml</value>
</list>
</property>
<!--defines the properties of Hibernate sessionfactory--
<property name= "Hibernateproperties" >
<props>
<!--specify Hibernate's connection dialect--
<prop key= "Hibernate.dialect" >org.hibernate.dialect.MySQLDialect</prop>
<!--different database connections, select create,update,create-drop--> at startup
<prop key= "Hibernate.hbm2ddl.auto" >update</prop>
</props>
</property>
</bean>

<!--Configure the DAO bean--> for the person persistence class
<bean id= "Persondao" class= "Lee. Persondaoimpl ">
<!--use dependency injection to pass in a reference to Sessionfactory
<property name= "sessionfactory" ><ref local= "Sessionfactory"/></property>
</bean>
</beans>

Applicationcontext.xml File Configuration Template

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.