Spring框架裡解析配置檔案的準確位置
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"?><!--
xmlns:xsi="
xmlns:context="
xsi:schemaLocation="
<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:
(1) parse XML as a dom structure in memory ( line 391 ) (2) 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:
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2724092/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- spring boot更改配置檔案 application.properties的位置Spring BootAPP
- C#中準確跟蹤錯誤異常所在的檔案位置方法C#
- 配置歸檔位置和檔案格式
- MySQL 配置檔案位置及命名。MySql
- Spring系列之手寫註解與配置檔案的解析Spring
- 正確映象檔案配置
- Nginx配置檔案解析Nginx
- redis配置檔案解析Redis
- Hibernate的配置檔案解析
- 深入解析 Spring 配置檔案:從基礎到高階Spring
- Spring Boot 框架中配置檔案 application.properties 當中的所有配置大全Spring Boot框架APP
- Benchmarksql的props配置檔案解析SQL
- 原始碼解析Flask的配置檔案原始碼Flask
- SSM框架整合(配置檔案)SSM框架
- SSM框架pom配置檔案SSM框架
- java解析yaml配置檔案JavaYAML
- DHCP常用配置檔案解析
- Nginx配置檔案示例解析Nginx
- Spring Boot 配置檔案Spring Boot
- Spring檔案最全配置Spring
- win10搜尋檔案在哪裡 檢視搜尋檔案位置的方法Win10
- python準確判斷檔案型別Python型別
- 【SSM框架整合】專案xml檔案、properties等檔案的配置SSM框架XML
- Spring Boot @PropertySource 載入指定配置檔案、@ImportResource 匯入Spring 配置檔案Spring BootImport
- 各作業系統下php.ini檔案的位置在哪裡作業系統PHP
- Spring - 配置檔案中的特殊字元Spring字元
- spring 載入配置檔案的方式Spring
- spring和Mybatis的核心配置檔案SpringMyBatis
- Spring Boot的配置檔案管理技巧Spring Boot
- 文盤Rust -- 配置檔案解析Rust
- rabbitMQ-Spring配置檔案MQSpring
- spring 配置檔案刨析Spring
- Spring 配置檔案詳解Spring
- spring配置檔案解釋Spring
- spring配置檔案詳解Spring
- 轉載:為什麼在 Spring 的配置裡,最好不要配置 xsd 檔案的版本號Spring
- tidb-server 的配置檔案在哪裡?TiDBServer
- ls命令統計檔案數量不準確