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

公众号编辑器排行榜网站建设优化推广教程

公众号编辑器排行榜,网站建设优化推广教程,wordpress文章采集插件,yellow在线观看大全目录 1. 基于XML配置文件 2. 基于XML注解方式声明bean 自定义bean 第三方bean 3.注解方式声明配置类 扩展1#xff0c;FactoryBean 扩展2,加载配置类并加载配置文件#xff08;系统迁移) 扩展3#xff0c;proxyBeanMethodstrue的使用 4. 使用Import注解导入要注入的bean…目录 1. 基于XML配置文件 2. 基于XML注解方式声明bean ·自定义bean ·第三方bean 3.注解方式声明配置类 扩展1FactoryBean 扩展2,加载配置类并加载配置文件系统迁移) 扩展3proxyBeanMethodstrue的使用 4. 使用Import注解导入要注入的bean对应的字节码 扩展4使用Import注解导入配置类 5. 编程式方式 6. 实现了ImportSelector接口 7.实现ImportBeanDefinitionRegistrar接口 8.实现了BeanDefinitionRegistryPostProcessor接口 总结 便于练习导一个比较大的包 dependencygroupIdorg.springframework/groupIdartifactIdspring-context/artifactIdversion5.3.23/version /dependency 1. 基于XML配置文件 !--声明自定义bean-- bean idbookService classcom.itheima.service.impl.BookServiceImpl scopesingleton/ !--声明第三方开发bean-- bean iddataSource classcom.alibaba.druid.pool.DruidDataSource/ /beans 2. 基于XML注解方式声明bean ·自定义bean ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:contexthttp://www.springframework.org/schema/contextxsi:schemaLocationhttp://www.springframework.org/schema/beanshttps://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsd context:component-scan base-packagecom.itheima/ /beans 使用注解如Component、Service、Repository等来标识Bean类 ·第三方bean 在配置类上写Component才可以被扫描到 Configuration也行更推荐 Component public class DbConfig { Bean public DruidDataSource getDataSource(){DruidDataSource ds new DruidDataSource();return ds;} } 3.注解方式声明配置类 Configuration //Configuration配置项如果不用于被扫描可以省略 ComponentScan(com.itheima) public class SpringConfig {Beanpublic DruidDataSource getDataSource(){DruidDataSource ds new DruidDataSource();return ds;} } 扩展1FactoryBean 初始化实现FactoryBean接口的类实现对bean加载到容器之前的批处理操作 public class BookFactoryBean implements FactoryBeanBook {public Book getObject() throws Exception {Book book new Book();// 进行book对象相关的初始化工作return book;}public Class? getObjectType() {return Book.class;} } public class SpringConfig8 {Beanpublic BookFactoryBean book(){return new BookFactoryBean();} } 扩展2,加载配置类并加载配置文件系统迁移) 在新的注解开发的项目中使用原来的老的配置文件使用ImportResource然后指定xml文件 Configuration ComponentScan(com.itheima) ImportResource(applicationContext-config.xml) public class SpringConfig2 { } 扩展3proxyBeanMethodstrue的使用 使用proxyBeanMethodstrue可以保障调用此方法得到的对象是从容器中获取的而不是重新创建的 默认是true Configuration(proxyBeanMethods true) public class SpringConfig3 {Beanpublic Book book(){System.out.println(book init ...);return new Book();} } 先拿到了配置类的对象从容器中获取再调用了方法得到的就是同一个对象 public class AppObject {public static void main(String[] args) {ApplicationContext ctx new AnnotationConfigApplicationContext(SpringConfig3.class);SpringConfig3 config ctx.getBean(SpringConfig3, SpringConfig3.class);SpringConfig3.book();SpringConfig3.book();} } 4. 使用Import注解导入要注入的bean对应的字节码 Import(Dog.class) public class SpringConfig5 { } 被导入的bean无需使用注解声明为bean public class Dog { } 此形式可以有效的降低源代码与Spring技术的耦合度在spring技术底层及诸多框架的整合中大量使用 扩展4使用Import注解导入配置类 使用这种方式可以加载配置类并且也不用加Configuration了 Import(DbConfig.class) public class SpringConfig {} 5. 编程式方式 ·使用上下文对象在容器初始化完毕后注入bean 这种只能使用AnnotationConfigApplicationContext其他不生效 public class AppImport {public static void main(String[] args) {AnnotationConfigApplicationContext ctx new AnnotationConfigApplicationContext(SpringConfig5.class);ctx.register(Cat.class);String[] names ctx.getBeanDefinitionNames();for (String name : names) {System.out.println(name);}} } 6. 实现了ImportSelector接口 导入实现了ImportSelector接口的类实现对导入源的编程式处理谁导入他他就能查谁的户口把他里面的注解方法等等全部可以获取到 在配置类上Import(MyImportSelector.class) public class MyImportSelector implements ImportSelector {public String[] selectImports(AnnotationMetadata metadata) {boolean flag metadata.hasAnnotation(org.springframework.context.annotation.Import);if(flag){return new String[]{com.itheima.domain.Dog};}return new String[]{com.itheima.domain.Cat};} } 7.实现ImportBeanDefinitionRegistrar接口 导入实现了ImportBeanDefinitionRegistrar接口的类通过BeanDefinition的注册器注册实名bean实现对容器中bean的裁定例如对现有bean的覆盖进而达成不修改源代码的情况下更换实现的效果 public class MyImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,BeanDefinitionRegistry registry) {BeanDefinition beanDefinition BeanDefinitionBuilder.rootBeanDefinition(BookServiceImpl2.class).getBeanDefinition();registry.registerBeanDefinition(bookService, beanDefinition);}} 8.实现了BeanDefinitionRegistryPostProcessor接口 导入实现了BeanDefinitionRegistryPostProcessor接口的类通过BeanDefinition的注册器注册实名bean实现对容器中bean的最终裁定 public class MyPostProcessor implements BeanDefinitionRegistryPostProcessor {public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) {BeanDefinition beanDefinition BeanDefinitionBuilder.rootBeanDefinition(BookServiceImpl4.class).getBeanDefinition();registry.registerBeanDefinition(bookService, beanDefinition);} } 总之实现了BeanDefinitionRegistryPostProcessor接口可以对最终的Bean定义产生影响可以动态地添加、修改或删除Bean定义从而对应用程序的配置和行为进行定制化。 总结
文章转载自:
http://www.morning.kczkq.cn.gov.cn.kczkq.cn
http://www.morning.wtdyq.cn.gov.cn.wtdyq.cn
http://www.morning.dbcw.cn.gov.cn.dbcw.cn
http://www.morning.bswnf.cn.gov.cn.bswnf.cn
http://www.morning.nxpqw.cn.gov.cn.nxpqw.cn
http://www.morning.mllmm.cn.gov.cn.mllmm.cn
http://www.morning.qysnd.cn.gov.cn.qysnd.cn
http://www.morning.knwry.cn.gov.cn.knwry.cn
http://www.morning.pftjj.cn.gov.cn.pftjj.cn
http://www.morning.skrrq.cn.gov.cn.skrrq.cn
http://www.morning.feites.com.gov.cn.feites.com
http://www.morning.xhrws.cn.gov.cn.xhrws.cn
http://www.morning.tnmmp.cn.gov.cn.tnmmp.cn
http://www.morning.sooong.com.gov.cn.sooong.com
http://www.morning.c7627.cn.gov.cn.c7627.cn
http://www.morning.gjzwj.cn.gov.cn.gjzwj.cn
http://www.morning.prmbb.cn.gov.cn.prmbb.cn
http://www.morning.jfwbr.cn.gov.cn.jfwbr.cn
http://www.morning.aiai201.cn.gov.cn.aiai201.cn
http://www.morning.cfcpb.cn.gov.cn.cfcpb.cn
http://www.morning.mlmwl.cn.gov.cn.mlmwl.cn
http://www.morning.rhsg.cn.gov.cn.rhsg.cn
http://www.morning.ygrkg.cn.gov.cn.ygrkg.cn
http://www.morning.dkslm.cn.gov.cn.dkslm.cn
http://www.morning.qzxb.cn.gov.cn.qzxb.cn
http://www.morning.fwgnq.cn.gov.cn.fwgnq.cn
http://www.morning.sfqtf.cn.gov.cn.sfqtf.cn
http://www.morning.jjhrj.cn.gov.cn.jjhrj.cn
http://www.morning.kyzja.com.gov.cn.kyzja.com
http://www.morning.ytbr.cn.gov.cn.ytbr.cn
http://www.morning.pwwjs.cn.gov.cn.pwwjs.cn
http://www.morning.bpmdz.cn.gov.cn.bpmdz.cn
http://www.morning.nflpk.cn.gov.cn.nflpk.cn
http://www.morning.bxbnf.cn.gov.cn.bxbnf.cn
http://www.morning.rwxnn.cn.gov.cn.rwxnn.cn
http://www.morning.syznh.cn.gov.cn.syznh.cn
http://www.morning.dfffm.cn.gov.cn.dfffm.cn
http://www.morning.jqllx.cn.gov.cn.jqllx.cn
http://www.morning.hmdn.cn.gov.cn.hmdn.cn
http://www.morning.jbxmb.cn.gov.cn.jbxmb.cn
http://www.morning.tbnn.cn.gov.cn.tbnn.cn
http://www.morning.jqjnl.cn.gov.cn.jqjnl.cn
http://www.morning.rjnrf.cn.gov.cn.rjnrf.cn
http://www.morning.xkzmz.cn.gov.cn.xkzmz.cn
http://www.morning.rghkg.cn.gov.cn.rghkg.cn
http://www.morning.wpcfm.cn.gov.cn.wpcfm.cn
http://www.morning.bljcb.cn.gov.cn.bljcb.cn
http://www.morning.hnkkm.cn.gov.cn.hnkkm.cn
http://www.morning.jfjqs.cn.gov.cn.jfjqs.cn
http://www.morning.czgtt.cn.gov.cn.czgtt.cn
http://www.morning.bwdnx.cn.gov.cn.bwdnx.cn
http://www.morning.gkjnz.cn.gov.cn.gkjnz.cn
http://www.morning.qygfb.cn.gov.cn.qygfb.cn
http://www.morning.sgfnx.cn.gov.cn.sgfnx.cn
http://www.morning.nzkkh.cn.gov.cn.nzkkh.cn
http://www.morning.sjsfw.cn.gov.cn.sjsfw.cn
http://www.morning.pypqf.cn.gov.cn.pypqf.cn
http://www.morning.rshijie.com.gov.cn.rshijie.com
http://www.morning.spxk.cn.gov.cn.spxk.cn
http://www.morning.dtnjr.cn.gov.cn.dtnjr.cn
http://www.morning.hysqx.cn.gov.cn.hysqx.cn
http://www.morning.yhrfg.cn.gov.cn.yhrfg.cn
http://www.morning.bsrcr.cn.gov.cn.bsrcr.cn
http://www.morning.ckntb.cn.gov.cn.ckntb.cn
http://www.morning.qrwdg.cn.gov.cn.qrwdg.cn
http://www.morning.gmmyn.cn.gov.cn.gmmyn.cn
http://www.morning.xsgxp.cn.gov.cn.xsgxp.cn
http://www.morning.tdmr.cn.gov.cn.tdmr.cn
http://www.morning.llthz.cn.gov.cn.llthz.cn
http://www.morning.srsln.cn.gov.cn.srsln.cn
http://www.morning.xflwq.cn.gov.cn.xflwq.cn
http://www.morning.zpjhh.cn.gov.cn.zpjhh.cn
http://www.morning.ydxwj.cn.gov.cn.ydxwj.cn
http://www.morning.kfbth.cn.gov.cn.kfbth.cn
http://www.morning.jpgfx.cn.gov.cn.jpgfx.cn
http://www.morning.ysqb.cn.gov.cn.ysqb.cn
http://www.morning.mtmnk.cn.gov.cn.mtmnk.cn
http://www.morning.fdzzh.cn.gov.cn.fdzzh.cn
http://www.morning.kabaifu.com.gov.cn.kabaifu.com
http://www.morning.cwyfs.cn.gov.cn.cwyfs.cn
http://www.tj-hxxt.cn/news/261015.html

相关文章:

  • 佛山网站设计资讯最全资源搜索引擎
  • 个人网站论文摘要特色设计网站推荐
  • 郑州个人网站建设公司排行榜便宜手机网站建设
  • 平乡企业做网站怎么做倒计时网站
  • 英国做电商网站有哪些方面app开发公司定制小程序
  • 网站开发学徒工作如何二维码生成器怎么弄
  • 网站建设方案设计杭州手机网站制作电脑公司
  • 东莞旅游网站建设微信公众号是干什么用的
  • 济南外贸建站做套现网站
  • 高端工作网站网站的网页设计毕业设计
  • 长沙网站优化对策替换wordpress logo
  • jsp网站开发难吗品牌的手机网站制作
  • 大连个人网站开发制作通州 网站建设
  • 做外贸的免费网站新津县网站建设
  • 网站渗透职场社交网站怎么做
  • linux删除WordPress商用营销型网站建设优化建站
  • 织梦只显示网站首页上海软件有限公司
  • 国外搜索关键词的网站消费返利系统网站建设
  • 建设一中校园网站镇江论坛
  • 深色系网站各行业的专业网址论坛资料
  • 用模板做的网站权重高吗dw外部网站链接怎么做
  • 网站开发视频 百度云网站 备案号查询
  • 哪些网站可以接单做wordpress微信小程式
  • 网站要钱吗?如何创网站
  • 北京公司网站建设报价表京津冀协同发展图片
  • 正常开发一个网站需要多少钱wordpress中调用文章内容
  • 免费网站网站制作平台网站开发成本如何入账
  • wordpress单位内网做网站网站开发应聘信息
  • wordpress企业网站制作wordpress的安装教程
  • 白云免费网站建设深圳市住房和建设局李秀钗