当前位置: 首页 > news >正文 网站网址怎么写爱站网主要功能 news 2025/10/22 9:16:09 网站网址怎么写,爱站网主要功能,多模室内设计网站,给自己的家乡建设网站上一节介绍了Spring创建过程中的两个重要的接口#xff0c;那么它们在创建Bean的过程中起到了什么作用呢#xff1f;接下来请看#xff1a; Spring有三种方式寻找 xml 配置文件#xff0c;根据 xml 文件内容来构建 ApplicationContext#xff0c;分别为ClassPathXmlAppli…上一节介绍了Spring创建过程中的两个重要的接口那么它们在创建Bean的过程中起到了什么作用呢接下来请看 Spring有三种方式寻找 xml 配置文件根据 xml 文件内容来构建 ApplicationContext分别为ClassPathXmlApplicationContextFileSystemXmlApplicationContext AnnotationConfigApplicationContext 和 AnnotationConfigServletWebApplicationContext。 动手创建Bean 创建接口实现类 public class beanImpl implements bean{Overridepublic void print() {System.out.println(bean);} } 创建xml文件 ?xml version1.0 encodingUTF-8 ? beans xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlnshttp://www.springframework.org/schema/beansxsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd default-autowirebyNamebean idbean classcom.beanImpl/ /beans 运行 public class A01Application {public static void main(String[] args) {ApplicationContext context new ClassPathXmlApplicationContext(classpath:bean.xml);context.getBean(bean.class).print();} }D:\jdk8\bin\java.exe -javaagent:F:\idea\IntelliJ IDEA 22:49:09.159 [main] DEBUG org.springframework.context.s 22:49:09.261 [main] DEBUG org.springframework.beans.fac 22:49:09.282 [main] DEBUG org.springframework.beans.fac bean进程已结束,退出代码0 那么读取xml的时候发生了什么事呢 内部实现 public static void main(String[] args) {DefaultListableBeanFactory beanFactory new DefaultListableBeanFactory();XmlBeanDefinitionReader xmlBeanDefinitionReader new XmlBeanDefinitionReader(beanFactory);xmlBeanDefinitionReader.loadBeanDefinitions(new ClassPathResource(bean.xml));for (String name : beanFactory.getBeanDefinitionNames()){System.out.println(name);}}D:\jdk8\bin\java.exe -javaagent:F:\idea\In 23:05:26.396 [main] DEBUG org.springframewo bean进程已结束,退出代码0 注解创建Bean public class A03Application {public static void main(String[] args) {AnnotationConfigApplicationContext context new AnnotationConfigApplicationContext(beanConfig.class);context.getBean(bean.class).print();for (String name : context.getBeanDefinitionNames()){System.out.println(name);}} }bean org.springframework.context.annotation.internalConfigurationAnnotationProcessor org.springframework.context.annotation.internalAutowiredAnnotationProcessor org.springframework.context.annotation.internalCommonAnnotationProcessor org.springframework.context.event.internalEventListenerProcessor org.springframework.context.event.internalEventListenerFactory beanConfig bean 与目标 VM 断开连接, 地址为: 127.0.0.1:64717传输: 套接字进程已结束,退出代码0 注解创建Bean会把配置类也作为Bean注入进来同时还会添加5个后处理器来进行对beanConfig的解析处理。 支持WEB的注解创建Bean 创建支持web的配置类 Configuration public class WebConfig {//创建Servlet的web服务器Beanpublic ServletWebServerFactory servletWebServerFactory(){return new TomcatServletWebServerFactory();}//创建前处理器用来接收各种请求Beanpublic DispatcherServlet dispatcherServlet(){return new DispatcherServlet();}//将dispatcherServlet注册在web服务器上Beanpublic DispatcherServletRegistrationBean dispatcherServletRegistrationBean(DispatcherServlet dispatcherServlet){return new DispatcherServletRegistrationBean(dispatcherServlet,/);}//Controller控制器Bean(/bean)public Controller controller(){return new Controller() {Overridepublic ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {System.out.println(bean);return null;}};} } 再运行一下主类吧 public class A04Application {public static void main(String[] args) {AnnotationConfigServletWebServerApplicationContext context new AnnotationConfigServletWebServerApplicationContext(WebConfig.class);for (String name : context.getBeanDefinitionNames()){System.out.println(name);}} }org.springframework.context.annotation.internalConfigurationAnnotationProcessor org.springframework.context.annotation.internalAutowiredAnnotationProcessor org.springframework.context.annotation.internalCommonAnnotationProcessor org.springframework.context.event.internalEventListenerProcessor org.springframework.context.event.internalEventListenerFactory webConfig servletWebServerFactory dispatcherServlet dispatcherServletRegistrationBean /bean 这样就能发现创建了所有的Bean而且还可以通过内置服务器运行接收请求。 to be continue······ 文章转载自: http://www.morning.cldgh.cn.gov.cn.cldgh.cn http://www.morning.xtkw.cn.gov.cn.xtkw.cn http://www.morning.kcbml.cn.gov.cn.kcbml.cn http://www.morning.wdpbq.cn.gov.cn.wdpbq.cn http://www.morning.ggcjf.cn.gov.cn.ggcjf.cn http://www.morning.zqzzn.cn.gov.cn.zqzzn.cn http://www.morning.jrqcj.cn.gov.cn.jrqcj.cn http://www.morning.nptls.cn.gov.cn.nptls.cn http://www.morning.nlnmy.cn.gov.cn.nlnmy.cn http://www.morning.yhpq.cn.gov.cn.yhpq.cn http://www.morning.rtspr.cn.gov.cn.rtspr.cn http://www.morning.krrjb.cn.gov.cn.krrjb.cn http://www.morning.khclr.cn.gov.cn.khclr.cn http://www.morning.tslfz.cn.gov.cn.tslfz.cn http://www.morning.rstrc.cn.gov.cn.rstrc.cn http://www.morning.lqpzb.cn.gov.cn.lqpzb.cn http://www.morning.rfwgg.cn.gov.cn.rfwgg.cn http://www.morning.rgrys.cn.gov.cn.rgrys.cn http://www.morning.pqjpw.cn.gov.cn.pqjpw.cn http://www.morning.krrjb.cn.gov.cn.krrjb.cn http://www.morning.swwpl.cn.gov.cn.swwpl.cn http://www.morning.tkrdg.cn.gov.cn.tkrdg.cn http://www.morning.fy974.cn.gov.cn.fy974.cn http://www.morning.ltdrz.cn.gov.cn.ltdrz.cn http://www.morning.nhdw.cn.gov.cn.nhdw.cn http://www.morning.hrgxk.cn.gov.cn.hrgxk.cn http://www.morning.jytrb.cn.gov.cn.jytrb.cn http://www.morning.yrngx.cn.gov.cn.yrngx.cn http://www.morning.nqmhf.cn.gov.cn.nqmhf.cn http://www.morning.yfqhc.cn.gov.cn.yfqhc.cn http://www.morning.pswzc.cn.gov.cn.pswzc.cn http://www.morning.xzgbj.cn.gov.cn.xzgbj.cn http://www.morning.qzsmz.cn.gov.cn.qzsmz.cn http://www.morning.htmhl.cn.gov.cn.htmhl.cn http://www.morning.txfzt.cn.gov.cn.txfzt.cn http://www.morning.xqcst.cn.gov.cn.xqcst.cn http://www.morning.mnsts.cn.gov.cn.mnsts.cn http://www.morning.grfhd.cn.gov.cn.grfhd.cn http://www.morning.lsfzq.cn.gov.cn.lsfzq.cn http://www.morning.sthp.cn.gov.cn.sthp.cn http://www.morning.hlzpb.cn.gov.cn.hlzpb.cn http://www.morning.ypxyl.cn.gov.cn.ypxyl.cn http://www.morning.kbgzj.cn.gov.cn.kbgzj.cn http://www.morning.znnsk.cn.gov.cn.znnsk.cn http://www.morning.zdxss.cn.gov.cn.zdxss.cn http://www.morning.ztjhz.cn.gov.cn.ztjhz.cn http://www.morning.jqjnx.cn.gov.cn.jqjnx.cn http://www.morning.mfbcs.cn.gov.cn.mfbcs.cn http://www.morning.rnwmp.cn.gov.cn.rnwmp.cn http://www.morning.hhskr.cn.gov.cn.hhskr.cn http://www.morning.xdnhw.cn.gov.cn.xdnhw.cn http://www.morning.zhqfn.cn.gov.cn.zhqfn.cn http://www.morning.rgsnk.cn.gov.cn.rgsnk.cn http://www.morning.fkdts.cn.gov.cn.fkdts.cn http://www.morning.qsyyp.cn.gov.cn.qsyyp.cn http://www.morning.geledi.com.gov.cn.geledi.com http://www.morning.zypnt.cn.gov.cn.zypnt.cn http://www.morning.rtbx.cn.gov.cn.rtbx.cn http://www.morning.tzcr.cn.gov.cn.tzcr.cn http://www.morning.bpmnj.cn.gov.cn.bpmnj.cn http://www.morning.tfpbm.cn.gov.cn.tfpbm.cn http://www.morning.zmwd.cn.gov.cn.zmwd.cn http://www.morning.bbxbh.cn.gov.cn.bbxbh.cn http://www.morning.bnbtp.cn.gov.cn.bnbtp.cn http://www.morning.wgrl.cn.gov.cn.wgrl.cn http://www.morning.mldrd.cn.gov.cn.mldrd.cn http://www.morning.jzlkq.cn.gov.cn.jzlkq.cn http://www.morning.sjwzz.cn.gov.cn.sjwzz.cn http://www.morning.plnry.cn.gov.cn.plnry.cn http://www.morning.jtfsd.cn.gov.cn.jtfsd.cn http://www.morning.cpktd.cn.gov.cn.cpktd.cn http://www.morning.khfk.cn.gov.cn.khfk.cn http://www.morning.gczzm.cn.gov.cn.gczzm.cn http://www.morning.xjnjb.cn.gov.cn.xjnjb.cn http://www.morning.dzzjq.cn.gov.cn.dzzjq.cn http://www.morning.qmkyp.cn.gov.cn.qmkyp.cn http://www.morning.qkgwx.cn.gov.cn.qkgwx.cn http://www.morning.jcfdk.cn.gov.cn.jcfdk.cn http://www.morning.jfbgn.cn.gov.cn.jfbgn.cn http://www.morning.gtqws.cn.gov.cn.gtqws.cn 查看全文 http://www.tj-hxxt.cn/news/239287.html 相关文章: 基础设施建设的网站网站开发怎么学习 网站网讯制作网页通常用什么定位 如何给自己建设的网站设置登陆用户名和密码免费网站打包app 迅速编程做网站哈尔滨网站制作公司价格 网站建设很简单陕西购物商城网站建设 门户网站是不是新媒体学编程哪家培训机构好 韩雪冬个人网站汕头市潮南区紧急提醒 网站维护有多长时间个人怎么做公司网站 网站的推广方法有哪些高中网站建设课程 崇左网站建设wordpress 左侧菜单栏 网站做icp备案需要多久特别炫酷的网站 今天三河燕郊确诊名单南宁seo公司哪家好 侯马做网站wordpress数据库e r图 山西建设工程信息网站黄页网址18岁以下勿入 公司做网站查看网站用什么语言做的 潍坊公司做网站住房城乡建设部执业资格注册中心网站 网站建设方案 百度文库电子商务网站建设的好处有哪些 自助建网站工具凡科 360免费建站 医疗类网站源码网站收录地址 萍乡网站推广泉州晋江网站建设 杭州百度seo优化seo百度刷排名 莆田外贸网站建设有哪些网站到期时间 网站空间送数据库辽宁工程建设信息网诚信库 网站集约化建设背景wordpress 淘宝主题 海宁网站建设公司推荐怎样搞网络营销 桂林网站优化注意事项wordpress区块链游戏 做网站开发要学多久明星个人网站建设方案 广州做网站app网站如何伪静态 郑州高端网站案例没有营业执照可以做网站吗 做公司网站的总结wordpress博客防红跳转插件