基于Springv5.2.17.RELEASE+Gradle+jdk8进行编译
环境准备- maven
- jdk8
- idea
官方网站:
https://github.com/spring-projects/spring-framework/tree/v5.2.17.RELEASE
选择版本
注意:5.3.X需要JDK17的环境,JDK8请下载5.2.X,否则编译会报错
修改build.gradle设置镜像
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" }
}
编译工作
1.编译compileTestJava模块
打开源码所在文件夹,在windows cmd命令中输入
gradlew :spring-oxm:compileTestJava
编译成功
导入后等待编译完成
测试 1.添加测试模块new->model->gradle–>输入模块名称
2.2测试dependencies {
testCompile group: ‘junit’, name: ‘junit’, version: ‘4.12’
compile(project(":spring-context")) }
@Configuration
@ComponentScan("com.peppa")
public class MainClass {
public static void main(String[] args) {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MainClass.class);
HelloService helloService = (HelloService) context.getBean("helloService");
helloService.sayHello();
}
}
@Component
public class HelloService {
public void sayHello(){
System.out.println("hello");
}
}
测试成功



