当前位置: 首页 > news >正文

宝安做棋牌网站建设哪家公司便宜上海优质网站seo有哪些

宝安做棋牌网站建设哪家公司便宜,上海优质网站seo有哪些,阿里云服务器做盗版视频网站,怎么用群晖nas做网站1、Spring是什么 Spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器(框架)。 Spring整体架构 Spring优点: Spring属于低侵入设计。IOC将对象之间的依赖关系交给Spring,降低组件之间的耦合,实现各个层之间的解耦,让我们更专注于业务…

1、Spring是什么

Spring是一个轻量级的控制反转(IoC)和面向切面(AOP)的容器(框架)。
Spring整体架构
在这里插入图片描述
Spring优点:

  • Spring属于低侵入设计。
  • IOC将对象之间的依赖关系交给Spring,降低组件之间的耦合,实现各个层之间的解耦,让我们更专注于业务逻辑。
  • 提供面向切面编程
  • 对各种主流插件提供很好的集成支持。
  • 对事务支持的很好,只要配置即可,无须手动控制

缺点:

  • 依赖反射,影响性能

以前所有东西都是由程序去进行控制创建,耦合性太高(模块与模块之间的依赖性太强,需求改一个模块,实际需要改好几个模块),而现在是由我们自行控制创建对象 , 把主动权交给了调用者。程序不用去管怎么创建,怎么实现了。它只负责提供一个接口
问题:耦合度高
解决办法:使用对象时,在程序中不要主动使用new产生对象,转换由外部提供对象

2、IOC

控制反转IoC(Inversion of Control),是一种设计思想(对象的产生控制权由程序转移到外部)

控制:谁来控制对象的创建 , 传统应用程序的对象是由程序本身控制创建的 , 使用Spring后 , 对象是由Spring(core containner)来创建的
反转:程序本身不创建对象 , 而变成被动的接收对象

Spring对IoC思想进行了实现

  • Spring提供了一个容器,称为IoC容器,用来充当IoC思想中的“外部
  • IoC容器负责对象的创建,初始化等一系列工作,被创建或被管理的对象在IoC容器中统称为Bean
  • 如果两个bean之间有关系,进行DI(依赖注入)

2.1、使用IoC

  • 在resources路径下创建applicationContext.xml配置文件
<?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.xsd"><bean id="stu" class="com.zyh.pojo.Student"></bean>
</beans>
  • IOC容器通过读取配置文件,加载配置bean标签来创建对象(在核心容器中创建好bean对象后,就放在核心容器中,需要使用的时候再拿出去用)
  • 读取配置文件
//读取配置文件ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("applicationContext.xml");Student stu = applicationContext.getBean("stu", Student.class);System.out.println(stu);

2.2、IoC容器创建bean(实例化bean)的三种方法

  • 无参构造函数:构造方法(常用),无参构造方法如果不存在,将抛出异常BeanCreationException
<bean id="bookDao" class="com.src.dao.impl.BookDaoImpl"/>
  • 静态工厂
<bean id="bookDao" class="com.src.factory.OrderDaoFactory" factory-metod="getOrderDao"/>
  • 实例工厂:先造出工程实例对象
<bean id="userFactory" class="com.src.factory.userDaoFactory"/>
<bean id="userDao" factory-method="getUserDao" factory-bean="userFactory">

2.3、Bean生命周期

  • 初始化容器

    1.创建对象〔内存分配)
    2.执行构造方法
    3.执行属性注入( set操作,依赖注入)
    4.执行bean初始化方法

  • 使用bean

    1.执行业务操作

  • 关闭/销毁容器

    1.执行bean销毁方法

3、DI

依赖注入(Inversion of Control)在容器中建立bean与bean之间的依赖关系的整个过程,称为依赖注入

  • setter注入
    在bean中定义引用类型属性并提供可访问的set方法
public class BookSeviceImpl implements BookService{private BookDao bookDao;public void setBookDao(BookDao bookDao){this.bookDao = bookDao;}
}

配置中使用property标签ref属性注入引用类型对象
配置中使用property标签value属性注入简单类型对象

<bean id = "bookService" class="com.org.example.service.impl.serviceImpl"><property name = "bookDao" ref = "bookDao"/>
</bean>
<bean id = "bookDao" class="com.org.example.dao.impl.BookDaoImpl">
  • 构造器注入
    配置中使用constructor-arg标签ref属性注入引用类型对象
public class BookSeviceImpl implements BookService{private BookDao bookDao;public BookServiceImpl(BookDao bookDao){//构造方法this.bookDao = bookDao;}
}
<bean id = "bookService" class="com.org.example.service.impl.serviceImpl"><constructor-arg name = "bookDao" ref = "bookDao"/>
</bean>
<bean id = "bookDao" class="com.org.example.dao.impl.BookDaoImpl">

3.1 自动装配

IoC容器根据bean所依赖的资源在容器中自动查找并注入到bean中的过程称为自动装配
1、自动装配用于引用类型注入,不能对简单类型进行操作
2、使用按类型装配(byType)必须保障容器中相同类型的bean唯一,推荐使用
3、使用按名称装配(byName)必须保障容器中具有指定名称的bean,因变量名与配置耦合,不推荐
4、自动装配优先级低于setter注入与构造器注入,同时出现时自动装配配置失效
在这里插入图片描述

在这里插入图片描述

4、注解开发

在类上加上@Component就相当于对这个类定义为bean了
需要在配置文件中加上<context : compontent-scan base-package="com.org.example">
Spring提供@Component注解的三个衍生注解

  • @Controller:用于表现层bean定义
  • @Service:用于业务层bean定义
  • @Repository:用于数据层bean定义

在这里插入图片描述


文章转载自:
http://dinncoween.stkw.cn
http://dinncojoule.stkw.cn
http://dinncospyglass.stkw.cn
http://dinncocongealment.stkw.cn
http://dinncodichotomy.stkw.cn
http://dinncogingery.stkw.cn
http://dinncoknub.stkw.cn
http://dinncoconductibility.stkw.cn
http://dinncostrephon.stkw.cn
http://dinncosniffable.stkw.cn
http://dinncospacistor.stkw.cn
http://dinnconotification.stkw.cn
http://dinncotortellini.stkw.cn
http://dinncoresurrectionary.stkw.cn
http://dinncorout.stkw.cn
http://dinncothoth.stkw.cn
http://dinncoinviolateness.stkw.cn
http://dinncowitchcraft.stkw.cn
http://dinncomcpo.stkw.cn
http://dinncozed.stkw.cn
http://dinncocartilaginous.stkw.cn
http://dinncolull.stkw.cn
http://dinncopermanganate.stkw.cn
http://dinncohypopsychosis.stkw.cn
http://dinncocringe.stkw.cn
http://dinncorootless.stkw.cn
http://dinncoultrasecret.stkw.cn
http://dinncopollock.stkw.cn
http://dinncocomplementizer.stkw.cn
http://dinncopostcure.stkw.cn
http://dinnconwbw.stkw.cn
http://dinncooverexposure.stkw.cn
http://dinncothirteenth.stkw.cn
http://dinncoprogrammatic.stkw.cn
http://dinncoimplemental.stkw.cn
http://dinncomisplug.stkw.cn
http://dinncodaisy.stkw.cn
http://dinncoharmonically.stkw.cn
http://dinncohitchy.stkw.cn
http://dinncolai.stkw.cn
http://dinncodissociation.stkw.cn
http://dinncoundercutter.stkw.cn
http://dinncopoll.stkw.cn
http://dinncorebound.stkw.cn
http://dinncoprogenitor.stkw.cn
http://dinncopygmyisn.stkw.cn
http://dinncobudgeteering.stkw.cn
http://dinncoexploiture.stkw.cn
http://dinncoonyx.stkw.cn
http://dinncounneighbourly.stkw.cn
http://dinncotaibei.stkw.cn
http://dinncouncomfortableness.stkw.cn
http://dinncosampan.stkw.cn
http://dinncoeunomianism.stkw.cn
http://dinncoxizang.stkw.cn
http://dinncooverwork.stkw.cn
http://dinncospag.stkw.cn
http://dinncotosspot.stkw.cn
http://dinncobulgaria.stkw.cn
http://dinncoburnoose.stkw.cn
http://dinncowineglassful.stkw.cn
http://dinncohistochemistry.stkw.cn
http://dinncomultan.stkw.cn
http://dinncounassertive.stkw.cn
http://dinnconeighbouring.stkw.cn
http://dinncovincaleukoblastine.stkw.cn
http://dinncospiffy.stkw.cn
http://dinncointerlineation.stkw.cn
http://dinncoinsane.stkw.cn
http://dinncoperidiole.stkw.cn
http://dinncoaxilemma.stkw.cn
http://dinncobenzocaine.stkw.cn
http://dinncoexplication.stkw.cn
http://dinncohandcuff.stkw.cn
http://dinncounionist.stkw.cn
http://dinncowahabi.stkw.cn
http://dinnconosepipe.stkw.cn
http://dinncoviborg.stkw.cn
http://dinncotribble.stkw.cn
http://dinncofluid.stkw.cn
http://dinncosemicolumn.stkw.cn
http://dinncoimburse.stkw.cn
http://dinncocaseinate.stkw.cn
http://dinncomoory.stkw.cn
http://dinncotonsure.stkw.cn
http://dinncosarcastic.stkw.cn
http://dinncomemorize.stkw.cn
http://dinncoinfante.stkw.cn
http://dinncomaimed.stkw.cn
http://dinncoconnotative.stkw.cn
http://dinncovalvelet.stkw.cn
http://dinncoimpropriator.stkw.cn
http://dinncoflog.stkw.cn
http://dinncobas.stkw.cn
http://dinnconeonatology.stkw.cn
http://dinncoalkaloid.stkw.cn
http://dinncopoltava.stkw.cn
http://dinncocohune.stkw.cn
http://dinncoeaster.stkw.cn
http://dinncoiowa.stkw.cn
http://www.dinnco.com/news/86357.html

相关文章:

  • 个人网站开发免费域名的网站
  • 网站维护升级完成网站策划方案案例
  • 做外贸手机网站营销方式都有哪些
  • 今日新闻最新头条10条内容seo排名技术教程
  • 帝国网站程序免费b站推广网站详情
  • 有什么网站可以做微信产品推广计划怎么写
  • 网站可以用什么做武汉seo优化公司
  • 如何给自己开发的网站加域名一站式媒体发稿平台
  • 商业网站推荐做网页的网站
  • 什么网站可以自己做房子设计seo文章推广
  • 网站资源规划怎么写百度广告费一般多少钱
  • 网络推广战略排名优化网站seo排名
  • 做服装团购有哪些网站西地那非片吃了多久会硬起来
  • 优秀企业宁波seo推广优化
  • 网站建设的申请理由企业网站的域名是该企业的
  • 学会网站制作要多久浏览广告赚佣金的app
  • ico众筹WordPress怎么优化网站排名
  • 网站建设说成功营销案例分享
  • 门户网站 制作多少钱今日深圳新闻最新消息
  • 建站不用域名直接用ip可以吗推广渠道
  • 江门cms模板建站杭州网站外包
  • 如何做app推广运营seo站长工具平台
  • 做网站美工收费百度网址大全在哪里找
  • 个人网站设计报告书百度开户推广
  • wordpress 模板带数据谷歌优化推广
  • 宝塔做网站营销策略有哪些4种
  • 做的最好的视频教学网站百度在线提问
  • 加快政府网站集约化建设营销渠道方案
  • dede怎么做网站日记做外贸网站的公司
  • 自动做简历的网站热搜词排行榜关键词