1. rely tool
- Gradle
- Git
- JDK1.8 +
- IntelliJ IDEA
I currently use the system version is macOS Mojave 10.14. So, if Pang is a Windows environment, fat to some questions, please send me a message at the planet.
Ignorant forced Susan Chan Susan Chan: According to the information received by now, looks like the main Windows environment will be set up to fail. If Pangyou really build it up, it is recommended to create a new project, to build a Spring Demo to debug.
? In short, our aim is that we must have to debug. Jiang Zi, in order to better read the Spring code.
In addition, we refer to the documentation provided by the official "Import-INTO-IDEA" .
Supplement 1: IntelliJ IDEA, please use the 2018 version, there is no build up before Panyou feedback, because IDEA version is too low.
2. Source pull
From the official repository https://github.com/spring-projects/spring-framework Fork
a warehouse of their own.
- Why
Fork
? Since the beginning of reading, debugging source code, we might write some notes, have their own warehouses, can be freely submitted. ? - Spring version is used herein
5.1.1.BUILD-SNAPSHOT
. - Using
IntelliJ IDEA
fromFork
out of the warehouse pull code. Because the Spring project is relatively large, it can pull the code from the repository will be longer.
After pulling completed, Gradle will start automatically Build project. Because the Build process, the download will depend very much, please be patient.
- ? But it is not quite determine whether Gradle will automatically Build project, anyway, I will. If you have a problem here, please give me a message.
3. precompiled spring-oxm
project
Open IDEA Terminal, enter the following command, and precompiled spring-oxm
items:
|
When you see BUILD SUCCESSFUL
, explain compile successfully.
? In addition, it a little uncertain, Gradle has been automatically above Build project, this step if needed. But it does not familiar with Gradle mechanism, official documents and required to do so under the influence do nothing. Ha ha ha ha.
Thanks [butterfly] students fall in the fingertips, tested, this is a must operate.
4. Run the sample
In spring-context
the project src/test/java/example
directory, it has provided some examples.
① resolve BeanDefinition their corresponding XML configuration file to process
Debug org.springframework.beans.factory.xml.XmlBeanDefinitionReaderTests
of #withFreshInputStream()
and #withImport()
two unit tests.
In contrast, the latter is a more <import />
analytical label. Of course, XmlBeanDefinitionReaderTests class, other methods may be simple Debugging. Pan You see the interest of Kazakhstan.
#factorySingleton()
The method, FactoryBean single embodiment of the unit test.
② loading process of Bean
You can debug org.springframework.beans.factory.xml.AbstractBeanFactoryTests
this unit test class methods.
Indeed, AbstractBeanFactoryTests is an abstract class, so that at run time, need to select the corresponding sub-categories, e.g. XmlListableBeanFactoryTests class.
③ flow of ClassPathXmlApplicationContext
You can debug org.springframework.context.support.ClassPathXmlApplicationContextTests
this unit test class methods. For example #testResourceAndInputStream()
methods.
④ resolve BeanDefinition's Properties profile to the corresponding process
Readings, very little practical use. The main purpose is to more in-depth understanding of BeanDefinitionReader design.
You can debug org.springframework.beans.factory.support.PropertiesBeanDefinitionReaderTests
this unit test in the method.
In addition, under the recommended reading "interpretation of the source of the spring beans - BeanDefinition parser" article.
⑤ debugging process related to Spring AOP
See "exhausted Spring source code analysis - AOP Source Simple Introduction"
⑥ debugging Spring Transaction related processes
See "Fine Spring source code analysis do - Transaction Source Simple Introduction"
⑦ Spring MVC debugging related processes
See "exhausted Spring MVC source code analysis - debugging environment to build."
⑧ TODO taro, add some examples of recommended reading
The problem may be encountered
5.1 there is no error reported InstrumentationSavingAgent
For example, he said in operation spring-context
when the unit test project, will report an error InstrumentationSavingAgent exist. At this point, we will be spring-context.gradle
amended as follows:
After editing, Gradle will automatically Build project, download the dependencies. When finished, re-run spring-context
the project unit tests passed.
According Pangyou] test [Tomy_Rich to say, those who reported XXX does not exist, and it is handled InstrumentationSavingAgent like it.
5.2 Report 'io.spring.dependency-management' plugin does not exist
Refer to "Plugin [id: 'io.spring.dependency- management', version: '1.0.5.RELEASE', apply: false] was not found in any of the following sources:" to resolve a paper.
Offers from Pangyou [] of Jiahe Ming.
5.3 Other
If you are in the process of building Pangyou debugging environment, if you encounter any problems, you can give me a message on the planet.
666. eggs
I began to update the source code parsing Spring series, let us together in 2019 exhausted Spring.
In addition, the author of well-based Friends of the small Domingo, has Sike Spring source code, and update the corresponding article. So for this series, if small Domingo has been written, directly referenced. Thanks articles authorization small Domingo. Alacrity.
Then, they begin to do it.
Tips important one:
"Spring Source depth analysis", based on analytical Spring 3 version of the source. Although the version a bit old, but fluency content is very good, especially the Spring IoC part. Nai Nai himself read read it, thumbs up.