Table of contents
spring5.x architecture
Data Access/Integration: Data Access/Integration Module: Provides support for data source operations, including support for jdbc, orm mapping framework, xml parsing, message queue, and transaction management.
Web module: provides support for web applications
Core Container core container module: implement spring container, mainly provide IoC/DI function
AOP module: Provides support for aspect-oriented programming (AOP)
Test test module: provides support for testing
Online documentation study:
http://docs.jcohy.com/docs/spring-framework/5.3.22/html5/zh-cn/index.html
Preparations for building a reading environment
name |
information |
Remark |
maven version |
3.x |
|
idea version |
2019 or above |
|
jdk version |
1.8+ |
Generally use 1.8 |
spring source code version |
V5.2.7 (5.x can be used) |
Address: https://github.com/spring-projects/spring-framework/tree/v5.2.7.RELEASE |
gradle |
It is OK to use the idea |
下载spring:https://github.com/spring-projects/spring-framework/tree/v5.2.7.RELEASE
Note: If git is slow, you can download it manually.
version introduction
name |
describe |
Remark |
alpha |
For the internal test version, there are many bugs, unstable, and constantly updated |
generally not used |
beta1、beta2... |
For the public beta version, it is more unstable than the alpha version, and the function is constantly updated |
generally not used |
RC |
It is used for the candidate version, after several beta versions, it is relatively stable, and it is used to prepare for the official release after fixing bugs |
test use |
M1、M2.. |
Milestone versions are generally versions with major improvements. |
less used |
GA、RELEASE、Stable、Final等 |
For production releases, stable releases. |
end use version |
source code compilation
configuration items
Unzip the downloaded package and open the location: spring-framework-5.2.7.RELEASE\gradle\wrapper
open gradle-wrapper
Modify the configuration: build.gradle under pring-framework-5.2.7.RELEASE The new configuration is as follows, add the Aliyun warehouse
repositories {
maven{ url 'https://maven.aliyun.com/nexus/content/groups/public/'}
maven{ url 'https://maven.aliyun.com/nexus/content/repositories/jcenter'}
mavenCentral()
maven { url "https://repo.spring.io/libs-spring-framework-build" }
}
Shield the id 'io.spring.gradle-enterprise-conventions' version '0.0.2' under the code plugins to avoid failure to download gradle.
enter compile
1. Compile
Open cmd in the root directory and execute as follows:
gradlew :spring-oxm:compileTestJava
The result is as follows:
Tip: BUILD SUCCESSFUL means success.
2. Import idea to compile
Import idea to compile.
Need to wait for a long time to compile (a bit long)
After the build is complete
3. Finally test the code
new module
select gradle
Fill in the custom module name
Open build.gradle (spring-hong-testing) and add dependencies as follows:
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile(project(":spring-context"))
}
add test code
package com.hong.service;
/**
* @ClassName TestIService
* @Description 测试服务
* @Author csh
* @Date 2023/1/11 14:37
*/
public interface TestIService {
void testSpringSourceBuild();
}
package com.hong.service.impl;
import org.springframework.stereotype.Service;
import com.hong.service.TestIService;
/**
* @ClassName TestIServiceImpl
* @Description spring验证类实现
* @Author csh
* @Date 2023/1/11 14:39
*/
@Service
public class TestIServiceImpl implements TestIService {
@Override
public void testSpringSourceBuild() {
System.out.println("spring build success!");
}
}
package com.hong;
import com.hong.service.impl.TestIServiceImpl;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/**
* @ClassName TestMain
* @Description 测试
* @Author csh
* @Date 2023/1/11 14:45
*/
@Configuration
@ComponentScan("com.hong")
public class TestMain {
public static void main(String[] args) {
AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext((TestMain.class));
TestIServiceImpl bean = applicationContext.getBean(TestIServiceImpl.class);
bean.testSpringSourceBuild();
}
}
result
> Task :spring-hong-testing:classes
> Task :spring-hong-testing:TestMain.main()
spring build success��
BUILD SUCCESSFUL in 50s
35 actionable tasks: 2 executed, 33 up-to-date
The remote build cache was disabled during the build due to errors.
14:57:52: Task execution finished 'TestMain.main()'.
Finally, after setting up the above environment, you can learn from the source code. Reference article: https://blog.csdn.net/weixin_39786760/article/details/125133008https://www.cnblogs.com/lusaisai/p/11686352.htmlhttps://www.jianshu.com/p/949bb16813a2