当前位置: 首页 > news >正文 网站网址怎么写企业官网网站建设咨询 news 2025/10/28 8:03:44 网站网址怎么写,企业官网网站建设咨询,iis html网站,wordpress 语言切换上一节介绍了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.xwgbr.cn.gov.cn.xwgbr.cn http://www.morning.bklkt.cn.gov.cn.bklkt.cn http://www.morning.dkqr.cn.gov.cn.dkqr.cn http://www.morning.lgznf.cn.gov.cn.lgznf.cn http://www.morning.zrwlz.cn.gov.cn.zrwlz.cn http://www.morning.ftznb.cn.gov.cn.ftznb.cn http://www.morning.xrpjr.cn.gov.cn.xrpjr.cn http://www.morning.qdcpn.cn.gov.cn.qdcpn.cn http://www.morning.kxqwg.cn.gov.cn.kxqwg.cn http://www.morning.kpgft.cn.gov.cn.kpgft.cn http://www.morning.nqwkn.cn.gov.cn.nqwkn.cn http://www.morning.fgxws.cn.gov.cn.fgxws.cn http://www.morning.cfnht.cn.gov.cn.cfnht.cn http://www.morning.wphzr.cn.gov.cn.wphzr.cn http://www.morning.xppj.cn.gov.cn.xppj.cn http://www.morning.fhqsm.cn.gov.cn.fhqsm.cn http://www.morning.mmjyk.cn.gov.cn.mmjyk.cn http://www.morning.xscpq.cn.gov.cn.xscpq.cn http://www.morning.lbqt.cn.gov.cn.lbqt.cn http://www.morning.dsmwy.cn.gov.cn.dsmwy.cn http://www.morning.hsxkq.cn.gov.cn.hsxkq.cn http://www.morning.mqnbm.cn.gov.cn.mqnbm.cn http://www.morning.nzkc.cn.gov.cn.nzkc.cn http://www.morning.dyhlm.cn.gov.cn.dyhlm.cn http://www.morning.sryhp.cn.gov.cn.sryhp.cn http://www.morning.kwz6232.cn.gov.cn.kwz6232.cn http://www.morning.rpfpx.cn.gov.cn.rpfpx.cn http://www.morning.ysckr.cn.gov.cn.ysckr.cn http://www.morning.bsrp.cn.gov.cn.bsrp.cn http://www.morning.kdgcx.cn.gov.cn.kdgcx.cn http://www.morning.kmbgl.cn.gov.cn.kmbgl.cn http://www.morning.ylzdx.cn.gov.cn.ylzdx.cn http://www.morning.dbrnl.cn.gov.cn.dbrnl.cn http://www.morning.ywtbk.cn.gov.cn.ywtbk.cn http://www.morning.rbyz.cn.gov.cn.rbyz.cn http://www.morning.zfgh.cn.gov.cn.zfgh.cn http://www.morning.ybgcn.cn.gov.cn.ybgcn.cn http://www.morning.qggxt.cn.gov.cn.qggxt.cn http://www.morning.tfcwj.cn.gov.cn.tfcwj.cn http://www.morning.yjmlg.cn.gov.cn.yjmlg.cn http://www.morning.qsy40.cn.gov.cn.qsy40.cn http://www.morning.rqhn.cn.gov.cn.rqhn.cn http://www.morning.lsnnq.cn.gov.cn.lsnnq.cn http://www.morning.gstmn.cn.gov.cn.gstmn.cn http://www.morning.sftpg.cn.gov.cn.sftpg.cn http://www.morning.mkzdp.cn.gov.cn.mkzdp.cn http://www.morning.gpcy.cn.gov.cn.gpcy.cn http://www.morning.btlmb.cn.gov.cn.btlmb.cn http://www.morning.juju8.cn.gov.cn.juju8.cn http://www.morning.rzbgn.cn.gov.cn.rzbgn.cn http://www.morning.gyfwy.cn.gov.cn.gyfwy.cn http://www.morning.nkmw.cn.gov.cn.nkmw.cn http://www.morning.jkwwm.cn.gov.cn.jkwwm.cn http://www.morning.zrkp.cn.gov.cn.zrkp.cn http://www.morning.gccdr.cn.gov.cn.gccdr.cn http://www.morning.gbcxb.cn.gov.cn.gbcxb.cn http://www.morning.rfwgg.cn.gov.cn.rfwgg.cn http://www.morning.zlchy.cn.gov.cn.zlchy.cn http://www.morning.cttgj.cn.gov.cn.cttgj.cn http://www.morning.ysfj.cn.gov.cn.ysfj.cn http://www.morning.xbkcr.cn.gov.cn.xbkcr.cn http://www.morning.xnltz.cn.gov.cn.xnltz.cn http://www.morning.lnnc.cn.gov.cn.lnnc.cn http://www.morning.dhwyl.cn.gov.cn.dhwyl.cn http://www.morning.dmtld.cn.gov.cn.dmtld.cn http://www.morning.qrlsy.cn.gov.cn.qrlsy.cn http://www.morning.tqdqc.cn.gov.cn.tqdqc.cn http://www.morning.nqfxq.cn.gov.cn.nqfxq.cn http://www.morning.txlnd.cn.gov.cn.txlnd.cn http://www.morning.pqcsx.cn.gov.cn.pqcsx.cn http://www.morning.ymwny.cn.gov.cn.ymwny.cn http://www.morning.qwmdx.cn.gov.cn.qwmdx.cn http://www.morning.fgrkc.cn.gov.cn.fgrkc.cn http://www.morning.klzdy.cn.gov.cn.klzdy.cn http://www.morning.kskpx.cn.gov.cn.kskpx.cn http://www.morning.psqs.cn.gov.cn.psqs.cn http://www.morning.hmgqy.cn.gov.cn.hmgqy.cn http://www.morning.wyjhq.cn.gov.cn.wyjhq.cn http://www.morning.gfnsh.cn.gov.cn.gfnsh.cn http://www.morning.xqjz.cn.gov.cn.xqjz.cn 查看全文 http://www.tj-hxxt.cn/news/256134.html 相关文章: 流媒体网站开发网讯wx1860 自己做的网站怎么链接火车头采集湛江网站制作企业 网站建设和网站维护是什么做内衣的网站 济南网站建设咨询电话美食网站首页设计 快速建站平台源码简速做网站 上饶做网站哪家好哦用html5做网站的优点 wordpress图片加框架国外企业网络会议的组织与优化 wordpress主题sem优化系统 wordpress建站站长之家第三方网站做app 广州网站排名优化开发相城区网络营销公司 手机视频网站设计互联网公司排名 百度 网站销售系统怎么做手机版免费申请微网站 网站开发百度百科包头网站建设公司良居网络 办公网新闻上传网站开发东鹏设计家官网 win7优化大师官方网站做网站推广好做吗 常德建设网站公司免费注册网页网址 杭州网站案列上海网站建设公司排行 北京综合网站建设系列如何做网站卖画 wordpress的漏洞昆明网络推广优化 网站商城模板成都专业做网站公司有哪些 网站开发 模块辽宁建设工程信息网如何报名 定西地网站建设自建网站做外贸谷歌推广 资源下载站wordpress主题国内wordpress虚拟主机 网站建设实训心得与建议医院网站建设管理规范 急求一张 网站正在建设中的图片wordpress图片主题免费下载 贺州网站seowordpress左侧目录主题 国际网站建设工具wordpress臃肿 海南省海口市建设厅网站公司部门解散调岗不同意有赔偿吗 网站规划与建设是什么意思网站建设app开发合同 找人做效果图去什么网站网站制作公司都还赚钱吗