Spring核心配置中的各项主要配置

1:spring的核心配置文件中的各种配置。

spring的核心配置文件的名字 叫做 applicationContext.xml,后期也可以通过配置文件中的配置修改名称,在web.xml中进行如下配置:

 
        contextConfigLocation
        classpath:spring/applicationContext*.xml

   

2:核心配置文件中关于dao层的配置。

(1):首先准备db.properties 配置文件,最简单的配置如下。

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://127.0.0.1:3306/demo?characterEncoding=utf-8
jdbc.username=root

jdbc.password=123456

(2):然后加载在核心配置文件中加载数据库文件.


(3):配置数据库连接池,配置类可以用BasicDatasource,也可以用阿里巴巴的配置核心类 DruidDataSource。

        destroy-method="close">
       
       
       
       
       
       

   

(4):spring和hibernate,和mybatis的整合主要是整合sessionFactory.和hibernate的一个整合。


         
         
             
         

和mybatis的一个整合.


   
       
       
       
       
   

(5):配置文件中关于事务的配置。

!-- 事务管理器 -->
            class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
       
       

   

(6)配置通知


   
       
           
           
           
           
           
           
           
           
           
           
       

   

(7)关于切面的配置。


   
                    pointcut="execution(* com.store.service.*.*(..))" />

   

(8)关于配置文件中的service层的配置。     扫描包下面所有的service层。

     

(9)关于注解注入的配置

    

(10)在进行配置的时候所需要引入的命名空间。

    xmlns:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    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-4.0.xsd
                                      http://www.springframework.org/schema/context http://www.springframework.org/s ... ing-context-4.0.xsd

                                      http://www.springframework.org/schema/aop 

                                      http://www.springframework.org/schema/aop/spring-aop-4.0.xsd     

                                      http://www.springframework.org/schema/tx       http://www.springframework.org/schema/tx/spring-tx-4.0.xsd

    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.0.xsd">

jar包导入的话,可以使用maven管理

你可能感兴趣的:(Spring,配置文件)