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

怎么在虚拟主机上发布网站免费windows7云主机

怎么在虚拟主机上发布网站,免费windows7云主机,东莞大岭山森林公园,深圳工业设计培训班文章目录1. IOC容器概念2. IOC底层原理3. IOC#xff08;接口#xff09;4. IOC操作Bean管理#xff08;概念#xff09;5. IOC操作Bean管理#xff08;基于xml方式#xff09;5.1 基于xml创建对象5.2 基于xml方式注入属性5.2.1 DI#xff1a;依赖注入#xff0c;就是注… 文章目录1. IOC容器概念2. IOC底层原理3. IOC接口4. IOC操作Bean管理概念5. IOC操作Bean管理基于xml方式5.1 基于xml创建对象5.2 基于xml方式注入属性5.2.1 DI依赖注入就是注入属性5.2.2 xml注入其他类型属性5.2.3 注入属性-外部bean5.2.4 注入属性-内部bean很多人喜欢用外部bean结构明显5.2.5 注入属性-级联赋值5.2.6 xml注入集合属性数组、List、Map、Set6. IOC操作Bean管理FactoryBean7、IOC操作Bean管理bean作用域8. IOCBean管理bean生命周期9. IOC操作Bean管理xml自动装配10. IOC操作Bean管理外部属性文件11. IOC操作Bean管理基于注解方式简化xml配置12. 基于注解方式实现属性注入13. 完全注解开发1. IOC容器概念 控制反转把对象创建和对象之间的调用过程交给Spring进行管理。使用IOC目的为了耦合度降低 2. IOC底层原理 XML解析、工厂设计模式、反射IOC过程 第一步xml配置文件配置创建的对象 bean iddao classcom.zsh.UserDao/bean第二步有service类和dao类创建工厂类 class UserFactory{public static UserDao getDao(){//1.xml解析 String classValue class属性值; //2.通过反射创建对象Class clazz Class.forName(classValue);return (UserDao)clazz.getDeclaredConstructor().newInstance();} }3. IOC接口 IOC思想基于IOC容器完成IOC容器底层就是对象工厂Spring提供IOC容器实现方式两个接口 BeanFactoryIOC容器基本实现是Spring内部的使用接口不提供开发人员进行使用。 加载配置获取文件时候不会创建对象在获取对象使用才去创建对象。ApplocationContextBeanFactory接口的子接口提供更多更强大的功能一般由开发人员进行使用。 加载配置文件时候就会把在配置文件中的对象进行创建。 ApplicationContext接口有实现类 4. IOC操作Bean管理概念 什么是Bean管理 Bean管理有两方面 Spring创建对象Spring注入属性 Bean管理操作有两种方式 基于xml配置文件方式实现基于注解方式实现 5. IOC操作Bean管理基于xml方式 5.1 基于xml创建对象 !-- 配置User对象 -- bean iduser classcom.spring.User/bean在spring配置文件中使用bean标签标签里面添加对应属性就可以实现对象创建在bean标签有很多属性介绍常用的属性 id属性唯一标识class属性类全路径包类路径 创建对象时候默认也是执行无参数构造方法完成对象创建。 5.2 基于xml方式注入属性 5.2.1 DI依赖注入就是注入属性 第一种注入方式set注入方式 创建类定义属性和对应的set方法在spring配置文件中配置对象创建配置属性注入。 bean idbook classzsh.spring.Book!--2.set方法注入属性--!--name类里面属性名称value向属性注入的值--property namebname value天龙八部/propertyproperty namebauthor value金庸/property /bean第二种注入方式有参数构造方式 创建类定义属性创建属性对应有参构造方法。在spring配置文件中配置。 xml !--3.有参构造注入属性-- bean idorders classzsh.spring.Ordersconstructor-arg nameoname valueabc/constructor-argconstructor-arg nameaddress valueChina/constructor-arg /beanp名称空间注入了解 使用p名称空间注入可以简化基于xml配置方式。 beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:phttp://www.springframework.org/schema/pxsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd进行属性注入在bean标签里面进行操作。 5.2.2 xml注入其他类型属性 字面量 null值 property nameaddressnull/null /property属性值包含特殊符号 !--属性值包含特殊符号1.把《》进行转义2.把带特殊符号内容写到CDATA中-- property namebnamevalue![CDATA[《天龙八部》]]/value /property5.2.3 注入属性-外部bean 创建两个类service类和dao类在service调用到里面的方法public interface UserDao {public abstract void update();} public class UserDaoImpl implements UserDao {Overridepublic void update() {System.out.println(dao update....);} } public class UserService {private UserDao userDao;public void setUserDao(UserDao userDao){this.userDao userDao;}public void add(){System.out.println(service add .....);userDao.update();} }在xml中配置!-- 1 service和dao对象创建 -- bean iduserService classzsh.service.UserService!--name属性类里面的属性名称ref属性创建userDaoImpl对象bean标签--property nameuserDao refuserDaoImpl/property /bean bean iduserDaoImpl classzsh.dao.Impl.UserDaoImpl/bean5.2.4 注入属性-内部bean很多人喜欢用外部bean结构明显 一对多关系部门和员工一个部门多个员工一个员工属于某一个部门 在实体类之间表示一对多关系员工表示所属部门使用对象类型属性进行表示//部门类 public class Dept {private String dname;public void setDname(String dname) {this.dname dname;} } //员工类 public class Emp {private String ename;private String gender;//员工属于某一个部门private Dept dept;public void setDept(Dept dept) {this.dept dept;}public void setEname(String ename) {this.ename ename;}public void setGender(String gender) {this.gender gender;} }在spring配置中进行配置。!-- 内部bean -- bean idemp classzsh.bean.Empproperty nameename valuelucky/propertyproperty namegender value女/propertyproperty namedeptbean iddept classzsh.bean.Deptproperty namedname value安保部/property/bean/property /bean5.2.5 注入属性-级联赋值 方式一同外部bean注入方式二xml配置如下需要在emp表给dept设置getter!-- 级联赋值 -- bean idemp classzsh.bean.Empproperty nameename valuelucky/propertyproperty namegender value女/propertyproperty namedept refdept/propertyproperty namedept.dname value技术部/property /bean bean iddept classzsh.bean.Deptproperty namedname value安保部/property /bean5.2.6 xml注入集合属性数组、List、Map、Set 创建类、定义数组、List、Map、Set类型属性生成对应set方法。public class Stu {private String[] courses;private ListString list;private MapString,String maps;private SetString sets;public void setCourses(String[] courses){this.courses courses;}public void setList(ListString list){this.list list;}public void setMaps(MapString,String maps){this.maps maps;}public void setSets(SetString sets){this.sets sets;} }在Spring配置文件进行配置。!-- 集合类型属性注入 -- bean idstu classzsh.shuzu.Stu!-- 数组类型属性注入 --property namecoursesarrayvaluejava/value/array/property!-- list类型属性注入,值是对象类型 --property namelistlistref beancourse1/refref beancourse2/ref/list/property!-- Map类型属性注入 --property namemapsmapentry keyJAVA valuejava/entry/map/property!-- Set类型属性注入 --property namesetssetvalueMySql/value/set/property /bean !--创建多个Course对象-- bean idcourse1 classzsh.shuzu.Courseproperty namecname valueSpring5框架/property /bean bean idcourse2 classzsh.shuzu.Courseproperty namecname valueMybatis框架/property /bean把集合注入部分提取出来。 在spring配置文件中引入名称空间util beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:utilhttp://www.springframework.org/schema/utilxmlns:phttp://www.springframework.org/schema/pxsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd使用标签完成list集合注入提取 util:list idbookListref beancourse1/ref /util:list !-- list类型属性注入,值是对象 -- property namecourseList refbookList/property注意面试中会问DI 和 IOC区别 DI 是 IOC中一种具体实现就表示依赖注入注入属性注入属性需要在创建对象的基础之上。 6. IOC操作Bean管理FactoryBean Spring有两种类型bean一种普通bean另一种工厂beanFactoryBean 普通bean在配置文件中定义bean类型就是返回类型上面的配置bean就是普通bean工厂bean在配置文件定义bean类型可以和返回值类型不一样 第一步创建类让这个类作为工厂bean实现接口FactoryBean第二步实现接口里面的方法在实现的方法中定义返回的bean类型public class MyBean implements FactoryBeanCourse {//定义返回beanOverridepublic Course getObject() throws Exception {Course course new Course();course.setCname(abc);return course;}Overridepublic Class? getObjectType() {return null;} }7、IOC操作Bean管理bean作用域 在Spring里面设置创建bean实例默认为单实例对象如何设置单实例还是多实例 在spring配置文件bean标签里面有属性scope用于设置scope属性值 默认值sigleton表示单实例对象 prototype表示多实例对象。 注意 sigleton和prototype区别 第一sigleton单实例prototype多实例 第二设置scope是sigleton时候加载spring配置文件时候就会创建单实例对象。 第三设置scope是prototype时候不是在加载spring配置文件时候创建对象在调用getBean方法时候创建多实例对象。 8. IOCBean管理bean生命周期 生命周期从对象创建到对象销毁的过程bean生命周期五步配置后置处理器七步 通过构造器创建bean实例无参数构造为bean的属性设置值和对其它bean引用调用set方法调用bean的初始化的方法需要进行配置初始化的方法bean可以使用了对象获取到了当容器关闭时候调用bean的销毁的方法需要进行配置销毁的方法 bean idxxx classxxx init-methodinitMethod destroy-methoddestroyMethodbean的后置处理器bean生命周期有七步创建类实现BeanPostProcessor并在xml配置成bean 把bean实例传递bean后置处理器的方法调用类的before调用bean的初始化的方法需要进行配置初始化的方法把bean实例传递bean后置处理器的方法调用类的after 9. IOC操作Bean管理xml自动装配 什么是自动装配 根据指定装配规则属性名称或者属性类型Spring自动将匹配的属性值进行注入。spring文件中配置Emp中有Dept属性 !--实现自动装配autowire属性常用两个值byName根据属性名称注入 注入bean的id值和类的属性名称一样byType根据属性类型注入 -- bean idemp classautowire.Emp autowirebyName/bean bean iddept classzsh.autowire.Dept/bean10. IOC操作Bean管理外部属性文件 直接配置数据库信息不展示了引入外部属性文件配置数据库连接池德鲁伊连接池 !-- 引入外部属性文件 -- context:property-placeholder locationclasspath:jdbc.properties/ !-- 配置连接池 -- bean iddataSource classcom.alibaba.druid.pool.DruidDataSourceproperty namedriverClassName value${jdbc.driverClassName}/propertyproperty nameurl value${jdbc.url}/propertyproperty nameusername value${jdbc.username}/propertyproperty namepassword value${jdbc.password}/property /bean11. IOC操作Bean管理基于注解方式简化xml配置 Spring针对Bean管理中创建对象提供注解 Component(value“”) Service(value“”) Controller(value“”) Repository(value“userDaoImp”) 上面四个注解功能是一样的都可以用来创建bean实例基于注解方式实现对象创建 第一步引入aop依赖jar包第二步开启组件扫描!--1 如果扫描多个包多个包使用逗号隔开 2.扫描包上层目录--context:component-scan base-package/第三步创建类在类上面添加创建对象注解 注意开启组件扫描细节配置!--示例一use-default-filtersfalse 表示现在不使用默认filter自己配置filtercontext:include-filter 表示扫描包下Controller注解 -- context:component-scan base-packagecom use-default-filtersfalsecontext:include-filter typeannotation expressionorg.springframework.stereotype.Controller/ /context:component-scan!-- 设置不去扫描哪些内容 -- context:component-scan base-packagecomcontext:exclude-filter typeannotation expressionorg.springframework.stereotype.Controller/ /context:component-scan12. 基于注解方式实现属性注入 Spring提供的注解 AutoWired根据属性类型进行自动装配 Qualifier(value“userDaoImp”)根据属性名称进行自动装配和Autowired一起使用 Reaource(name“userDaoImp”)可以根据类型注入也可以根据名称注入 注意此注解的包是javax中的不是spring中的 Value注入普通类型属性 13. 完全注解开发 创建配置类替代xml配置文件 Configuration //配置类替代xml配置文件ComponentSean(basePackage{}) //包扫描public class SpringConfig{ }编写测试类 ApplicationContext context new AnnotationConfigApplicationContext(SpringConfig.class);
http://www.w-s-a.com/news/203197/

相关文章:

  • 东莞营销网站制作做一个网站建设
  • 啥网站都能看的浏览器下载网站后台管理系统展望
  • 新建站点步骤汉中 wordpress联盟
  • 坪山网站设计的公司网站 seo 设置
  • 济南网站设计公司排名如何免费注册网站域名
  • 网站开发分工甜妹妹福利wordpress
  • 网站中英文要怎么做网站建设的策划文案
  • 合肥推广外包公司佛山seo
  • 成都网站品牌设计策划课堂网站开发
  • 做直播网站赚钱公司网站空间怎么续费
  • 企业网站制作公司有哪些太原网站建设 thinkphp3.2
  • 云集网站哪个公司做的百度竞价排名怎么做
  • 做网站公司赚钱吗网站建设英语翻译
  • 网络公司除了做网站产品设计作品
  • dede网站模板替换湘潭建设路街道网站
  • 东莞网站优化效果如何网络设计工作
  • 网站备案系统验证码出错的解决方案任丘建设银行网站
  • 个人博客建站wordpress叮当app制作
  • 网站式的公司记录怎么做二手书网站策划书
  • 营销型网站的建设重点是什么帝国程序和WordPress
  • 正能量网站推荐不需要下载巴中网站建设开发公司
  • 学生模拟网站开发西安seo平台
  • 免费的app推广平台免费网站seo
  • 建一个个人网站网站建设中小企业广西
  • 优惠券网站做淘客违规吗个人建网站运营.
  • 旅游网站制作建设华大基因 网站建设
  • sem推广竞价托管南京seo网站优化
  • 网站优化网站建站教程网站建设 成都
  • 网站 配色表html代码在线
  • 城乡和建设部建造师网站众筹平台网站建设