2021-04-14

Spring工程搭建
spring基础包:1.spring-core:Core模块主要包含Spring框架基本的核心工具类,Spring的其他组件要都要使用到这个包里的类,Core模块是其他组件的基本核心
2.spring-beans:包含访问配置文件、创建和管理bean以及进行IOC/DI操作相关的所有类
3.spring-context:Spring的上下文即IOC容器,通过上下文可以获得容器中的Bean
4.spring-expression:EL表达式语言用于在运行时查询和操纵对象 <!-https://mvnrepository.com/artifact/org.springframework/spring-core --> org.springframework spring-core 5.2.13.RELEASE <!-https://mvnrepository.com/artifact/org.springframework/spring-beans --> org.springframework spring-beans 5.2.13.RELEASE org.springframework spring-context 5.2.13.RELEASE org.springframework spring-expression 5.2.13.RELEASE

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

2:核心配置文件中关于dao层的配置。
(1):首先准备db.properties 配置文件,最简单的配置如下。 jdbc.driver=com.mysql.jdbc.Driverjdbc.url=jdbc:mysql://127.0.0.1:3306/demo?characterEncoding=utf-8jdbc.username=rootjdbc.password=123456
(2):然后加载在核心配置文件中加载数据库文件. <context:property-placeholder location="/>

(3):配置数据库连接池,配置类可以用BasicDatasource,也可以用阿里巴巴的配置核心类 DruidDataSource。
后期需要可以在其中添加多个属性配置。
(4):spring和hibernate,和mybatis的整合主要是整合sessionFactory. 和hibernate的一个整合。
和mybatis的一个整合.
(5):配置文件中关于事务的配置。< !-- 事务管理器 --> !-- 事务管理器 -->
配置通知 <tx:advice id=“txAdvice” transaction-manager=“transactionManager”> tx:attributes <tx:method name=“save*” propagation=“REQUIRED” /> <tx:method name=“insert*” propagation=“REQUIRED” /> <tx:method name=“add*” propagation=“REQUIRED” /> <tx:method name=“create*” propagation=“REQUIRED” /> <tx:method name=“delete*” propagation=“REQUIRED” /> <tx:method name=“update*” propagation=“REQUIRED” /> <tx:method name=“find*” propagation=“SUPPORTS” read-only=“true” /> <tx:method name=“select*” propagation=“SUPPORTS” read-only=“true” /> <tx:method name=“get*” propagation=“SUPPORTS” read-only=“true” /> </tx:attributes> </tx:advice>
关于切面的配置。 aop:config <aop:advisor advice-ref=“txAdvice” pointcut=“execution(* com.store.service…(…))” /> </aop:config>
关于配置文件中的service层的配置。 扫描包下面所有的service层。 <context:comp

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值