Idea构建、编译Spring源码

Idea构建、编译Spring源码

  1. 软件准备

    • JDK版本:1.8.0_231

      https://download.csdn.net/download/Keiissland/11990344
      
    • Gradle版本:gradle-4.9

      https://downloads.gradle-dn.com/distributions/gradle-4.9-bin.zip
      
    • Spring版本:spring-framework-5.0

      https://github.com/spring-projects/spring-framework/tree/5.0.x
      
    • idea版本:ideaIU-2019.2.3

      http://www.jetbrains.com/idea/download/#section=windows
      
  2. 环境准备

    • JDK安装及配置(略)

    • Gradle安装、配置、集成idea

      • 参考地址:

        https://blog.csdn.net/weixin_42717959/article/details/84858021
        
  3. 项目检出

    • 采用Git地址clone的方式(https://github.com/spring-projects/spring-framework.git)

      0

    • 导入项目
      1

    • 等待Jar包的下载
      2

    • 配置一下Gradle(File --> Settings --> Gradle)
      3

  4. 编译项目

    • 使用Gradle中的compileTestJava,用于跑项目中的单元测试(会连带编译项目),期间控制台出现乱码不必理会
      4

    • 编译结束
      5

  5. 编写测试工程(spring-helloword)

    • 在总工程下,新建一个Module
      6

    • 项目类型为Gradle
      7

    • 设置项目名为spring-helloworld
      8

    • 设置路径
      9

    • 项目新建完毕(左面的项目文件都会展开)
      10

    • 在新建的spring-helloword项目中,导入spring-context依赖
      11

    • 编写测试代码
      12

    • 具体代码

      /**
       * Config.java
       */
      @ComponentScan("com.keiissland.helloworld")
      public class Config {
      }
      
      /**
       * HelloService.java
       */
      @Service
      public class HelloService {
      
      	public void sayHello() {
      		System.out.println("Hello World! ");
      	}
      }
      
      /**
       * Application.java
       */
      public class Application {
      
      	public static void main(String[] args) {
      		
              AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(Config.class);
      		
              HelloService helloService = (HelloService) context.getBean("helloService");
      		
              helloService.sayHello();
      	}
      }
      
  6. 运行测试工程代码出现的错误

    • 错误一

      Error:(354, 51) java: 找不到符号
      符号: 变量 CoroutinesUtils
      位置: 类 org.springframework.core.ReactiveAdapterRegistry.CoroutinesRegistrar
      

      解决方式

      https://blog.csdn.net/ULiYJ/article/details/95760122
      
    • 错误二

      Error:(26, 38) java: 找不到符号
      符号: 类 InstrumentationSavingAgent
      位置: 程序包 org.springframework.instrument 
      

      解决方式
      在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值