• Win10 + IDEA2019.3 搭建Spring5.1.x 源码开发环境


    本机环境:

    • Win10 家庭版64位
    • IDEA 2019.3.1
    • Spring 5.1.x
    • Gradle 5.6.4
    • Git 2.20.1

    0、编译环境初始化

    如上所述的环境都安装好,配置好环境变量:
    GRADLE_HOME:
    在这里插入图片描述
    GRADLE_USER_HOME:
    在这里插入图片描述
    然后在CMD查看Gradle的版本如下即表示配置成功:
    在这里插入图片描述

    1、下载Spring源码

    我是用git clone 码云的这个镜像下来后,切换到5.1.x 分支。

    2、编译-导入源码

    Spring-framework的源码目录有个导入IDEA的说明文档:import-into-idea.md,内容如下:

    _Within your locally cloned spring-framework working directory:_
    
    1. Precompile `spring-oxm` with `./gradlew :spring-oxm:compileTestJava`
    2. Import into IntelliJ (File -> New -> Project from Existing Sources -> Navigate to directory -> Select build.gradle)
    3. When prompted exclude the `spring-aspects` module (or after the import via File-> Project Structure -> Modules)
    4. Code away
    

    1、我们cmd进入这个根目录,然后先编译spring-oxm这个工程,因为其它spring组件会依赖这个。
    2、IDEA里面导入这个根目录工程:
    在这里插入图片描述
    选择Spring-framework目录后,选择导入方式为Gradle,然后点击finish:
    在这里插入图片描述

    3、然后点击File -- Project Structure 进去 modules里面排除 Spring-aspect 目录:
    在这里插入图片描述

    5、然后,修改Gradle配置文件,修改版本为 5.6.4:
    D:\Study\Spring-framework-5.1.x-gitee\Spring-Framework\gradle\wrapper\gradle-wrapper.properties

    distributionBase=GRADLE_USER_HOME
    distributionPath=wrapper/dists
    distributionUrl=file\:/D:/DevEnv/gradle-5.6.4-bin.zip
    zipStoreBase=GRADLE_USER_HOME
    zipStorePath=wrapper/dists
    
    

    distributionUrl 这个参数的值改为指向你本地的下载的 5.6.4 的zip包路径

    同时修改Cache.properties 里面的Gradle为对应的版本:
    D:\Study\Spring-framework-5.1.x-gitee\Spring-Framework.gradle\buildOutputCleanup\cache.properties
    在这里插入图片描述
    然后,在IDEA里面配置Gradle为你自己的版本:
    在这里插入图片描述

    最后,在IDEA里面打开一个终端Terminate,输入命令进行编译即可:
    在这里插入图片描述

    编译完成后,IDEA会自动建立工程的资源索引,然后展开工程目录,所有的Spring组件包的目录,左侧的文件夹图标都是有右下角那个蓝色标识的,才标识编译完成
    在这里插入图片描述

    如果出现编译时Spring-tx 这个模块无法编译通过,提示找不到这个IBM的jar包:

    Could not find com.ibm.websphere:uow:6.0.2.17.
    Searched in the following locations:
      - file:/C:/Users/Administrator/.m2/repository/com/ibm/websphere/uow/6.0.2.17/uow-6.0.2.17.pom
      - file:/C:/Users/Administrator/.m2/repository/com/ibm/websphere/uow/6.0.2.17/uow-6.0.2.17.jar
      - https://maven.aliyun.com/repository/public/com/ibm/websphere/uow/6.0.2.17/uow-6.0.2.17.pom
      - https://maven.aliyun.com/repository/public/com/ibm/websphere/uow/6.0.2.17/uow-6.0.2.17.jar
      - http://nexus.bsdn.org/content/groups/public/com/ibm/websphere/uow/6.0.2.17/uow-6.0.2.17.pom
      - http://nexus.bsdn.org/content/groups/public/com/ibm/websphere/uow/6.0.2.17/uow-6.0.2.17.jar
      - https://repo.maven.apache.org/maven2/com/ibm/websphere/uow/6.0.2.17/uow-6.0.2.17.pom
      - https://repo.maven.apache.org/maven2/com/ibm/websphere/uow/6.0.2.17/uow-6.0.2.17.jar
    Required by:
        project :spring-tx
    

    在这里插入图片描述

    解决办法是需要自己到mavenrepo上下载jar手动install到自己本地的maven仓库:

    mvn install:install-file -Dfile=uow-6.0.2.17.jar -DgroupId=com.ibm.websphere -DartifactId=uow -Dversion=6.0.2.17 -Dpackaging=jar
    

    然后重新编译即可。

  • 相关阅读:
    System.Runtime.InteropServices.COMException: 拒绝
    Struts中Action里对Form的运用理解
    Structs中<logic:present><logic:iterator>的使用
    AspxGridView控件自写数据源时出现删错行的问题
    AspxGridView绑定自主数据源的操作
    水晶报表发布后logon failed,Error Code:ox
    lock skew detected. Your build may be incomplete
    linux ulimit调优
    Erlang服务器内存耗尽bug跟踪过程
    erlang lists 系列函数功能与用法详解(共68个函数)
  • 原文地址:https://www.cnblogs.com/xiaocy/p/12442519.html
Copyright © 2020-2023  润新知