首页 文章 精选 留言 我的

精选列表

搜索[容器配置],共10000篇文章
优秀的个人博客,低调大师

一个快速找到Spring框架是在哪里找到XML配置文件并解析Beans定义的小技巧

We can define bean configuration in xml and then can get instantiated bean instance with help of all kinds of containers for example ClassPathXmlApplicationContext as displayed below: The content of Beans.xml: <?xml version="1.0" encoding="UTF-8"?> <!-- http://stackoverflow.com/questions/18802982/no-declaration-can-be-found-for-element-contextannotation-config --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <bean id="helloWorld" class="main.java.com.sap.HelloWorld"> <property name="message" value="sss"/> <property name="testMin" value="2"/> <property name="phone" value="1"/> </bean> </beans> Where can we set breakpoint to start? No hint. Here is a tip: we can make the Beans.xml invalid by deliberately changing te tag bean to beana, and relaunch application. Now exception is raised as expected: Click the hyperlink XmlBeanDefinitionReader.java:399, The line 399 where exception is raised will be automatically located. The core logic to load xml file is just near the exception raise position: line 391. So we can set breakpoint in line 391 now: Change the tag from beana back to bean, and start application via debug mode. The code below is the core logic of Bean configuration file parse in Spring framework. The logic consists of two main steps: parse XML as a dom structure in memory ( line 391 ) extract bean information contained in dom structure and generate BeanDefinition structure ( line 392 ) from screenshot below we can find out the xml is parsed via SAX parser: My “helloWorld” bean is parsed here: 本文来自云栖社区合作伙伴“汪子熙”,了解相关信息可以关注微信公众号"汪子熙"。

优秀的个人博客,低调大师

18、 Python快速开发分布式搜索引擎Scrapy精讲—Scrapy启动文件的配置—xpath表达式

【http://www.bdyss.cn】 【http://www.swpan.cn】 我们自定义一个main.py来作为启动文件 main.py #!/usr/bin/envpython #-*-coding:utf8-*- fromscrapy.cmdlineimportexecute#导入执行scrapy命令方法 importsys importos sys.path.append(os.path.join(os.getcwd()))#给Python解释器,添加模块新路径,将main.py文件所在目录添加到Python解释器 execute(['scrapy','crawl','pach','--nolog'])#执行scrapy命令 爬虫文件 #-*-coding:utf-8-*- importscrapy fromscrapy.httpimportRequest importurllib.response fromlxmlimportetree importre classPachSpider(scrapy.Spider): name='pach' allowed_domains=['blog.jobbole.com'] start_urls=['http://blog.jobbole.com/all-posts/'] defparse(self,response): pass xpath表达式 1、 2、 3、 基本使用 allowed_domains设置爬虫起始域名start_urls设置爬虫起始url地址parse(response)默认爬虫回调函数,response返回的是爬虫获取到的html信息对象,里面封装了一些关于htnl信息的方法和属性 responsehtml信息对象下的方法和属性response.url获取抓取的rulresponse.body获取网页内容response.body_as_unicode()获取网站内容unicode编码xpath()方法,用xpath表达式过滤节点extract()方法,获取过滤后的数据,返回列表 #-*-coding:utf-8-*- importscrapy classPachSpider(scrapy.Spider): name='pach' allowed_domains=['blog.jobbole.com'] start_urls=['http://blog.jobbole.com/all-posts/'] defparse(self,response): leir=response.xpath('//a[@class="archive-title"]/text()').extract()#获取指定标题 leir2=response.xpath('//a[@class="archive-title"]/@href').extract()#获取指定url print(response.url)#获取抓取的rul print(response.body)#获取网页内容 print(response.body_as_unicode())#获取网站内容unicode编码 foriinleir: print(i) foriinleir2: print(i) 【转载自:http://www.lqkweb.com】

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册