Spring Environment Construction

Source: Internet
Author: User

1. Import the jar package:

2. configuration file-applicationcontext.xml:

Add Schema constraint, location:spring-framework-3.2.0.release-"docs-" spring-framework-reference-"html-" Xsd-config.html

Re-configure Service

<?XML version= "1.0" encoding= "UTF-8"?><Beansxmlns= "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/bean S/spring-beans.xsd ">    <!--Configure the object ID to be created for service <bean> configuration: The class used to obtain the instance from the Spring container later: The fully qualified class name of the instance to be created -    <BeanID= "Userserviceid"class= "COM.ITHEIMA.A_IOC." Userserviceimpl "></Bean></Beans>
Applicationcontext.xml

Second, it can be configured to load the JDBC properties file, the data source, the spring framework for integrating hibernate factory beans, transaction managers, component scans, introduction of annotation parsers, transaction annotations, and so on. Such as:

<?XML version= "1.0" encoding= "UTF-8"?><Beansxmlns= "Http://www.springframework.org/schema/beans"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"Xmlns:context= "Http://www.springframework.org/schema/context"XMLNS:AOP= "HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP"Xmlns:tx= "Http://www.springframework.org/schema/tx"xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spri Ng-beans.xsd Http://www.springframework.org/schema/context http://www.spring                        Framework.org/schema/context/spring-context.xsd HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP Http://www.springframework.org/schema/aop/spring-aop.xsd HTTP://WWW.SPRINGFRAMEWORK.O Rg/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd ">        <!--loading the JDBC properties file -    <Context:property-placeholder Location= "Classpath:jdbc.properties"/>                            <!--Data Source -    <BeanID= "DataSource"class= "Com.mchange.v2.c3p0.ComboPooledDataSource">        < Propertyname= "Driverclass"value= "${driverclass}"/>        < Propertyname= "Jdbcurl"value= "${jdbcurl}"/>        < Propertyname= "User"value= "${user}"/>        < Propertyname= "Password"value= "${password}"/>    </Bean>    <!--Spring Framework for integration of Hibernate factory beans -    <BeanID= "Sessionfactory"class= "Org.springframework.orm.hibernate3.LocalSessionFactoryBean">        < Propertyname= "DataSource"ref= "DataSource"/>        <!--inject Hibernate-related properties -        < Propertyname= "Hibernateproperties">            <Props>                <propKey= "Hibernate.dialect">Org.hibernate.dialect.MySQL5Dialect</prop>                <propKey= "Hibernate.show_sql">True</prop>                <propKey= "Hibernate.format_sql">True</prop>                <propKey= "Hibernate.hbm2ddl.auto">Update</prop>            </Props>        </ Property>        <!--mapping files that are injected into hibernate -        < Propertyname= "Mappingdirectorylocations">            <List>                <value>Classpath:com/itheima/bos/domain</value>            </List>        </ Property>    </Bean>        <!--transaction manager -    <BeanID= "TransactionManager"class= "Org.springframework.orm.hibernate3.HibernateTransactionManager">        < Propertyname= "Sessionfactory"ref= "Sessionfactory"/>    </Bean>        <!--Component Scan -    <Context:component-scanBase-package= "Com.itheima.bos"/>    <!--Introducing the Annotation parser -    <Context:annotation-config/>    <!--Transaction Annotations -    <Tx:annotation-driven/></Beans>
Applicationcontext.xml

Spring Environment Construction

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.