spring 5.2.7 编译

  1. 环境
    idea 2021社区版
    jdk8
  2. 下载spring源码
    a、git上下载spring5.2.7 zip包,解压缩
    b、修改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" }
            }

    c、下载gradle-5.6.4-bin.zip

    d、修改gradle\wrapper\ 目录下的gradle-wrapper.properties,注释掉原distributionUrl配置,以免从网上下载gradle。

    #distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
    distributionUrl=file:///D:/.gradle/wrapper/dists/gradle-5.6.4-bin.zip

    e、编译compileTestJava模块

    执行gradlew.bat或在spring源码根目录里运行windows cmd,执行以下命令 

gradlew :spring-oxm:compileTestJava

    配置了镜像一般很快(1-3)分钟就能完成,如果要很久说明镜像配置不成功

   3. 导入idea

Import into IntelliJ (File -> New -> Project from Existing Sources -> Navigate to directory -> Select build.gradle)

    idea配置:

导入后编译需要一段时间。

4 添加测试模块

new->model->gradle-->输入模块名称
@Service
public class TestImpl {

    public void hello(){
        System.out.println("Hello Spring!");
    }
}
复制代码
@Configuration
@ComponentScan("com.test")
public class TestClass {

    public static void main(String[] args) {
        ApplicationContext context=new AnnotationConfigApplicationContext(TestClass.class);
        TestImpl bean = context.getBean(TestImpl.class);
        bean.hello();
    }
}
复制代码

5 大功告成

 

 

 

posted @   老皮肉  阅读(121)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
历史上的今天:
2017-05-09 揭示同步块索引(上):从lock开始
点击右上角即可分享
微信分享提示