Spring 6.x源码编译

环境

创建init.grade文件

相当于maven的settings.xml,全局加速拉取依赖

allprojects {
    repositories {
        mavenLocal()
        maven { url "https://maven.aliyun.com/repository/public" }
        maven { url 'https://maven.aliyun.com/repository/central' }
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/google' }
        maven { url 'https://maven.aliyun.com/repository/spring' }
        maven { url 'https://maven.aliyun.com/repository/grails-core' }
        maven { url 'https://maven.aliyun.com/repository/apache-snapshots' }
        jcenter()
        mavenCentral()
    }
    buildscript {
        repositories {
            mavenLocal()
            maven { url 'https://maven.aliyun.com/repository/public' }
            maven { url 'https://maven.aliyun.com/repository/central' }
            maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
            maven { url 'https://maven.aliyun.com/repository/spring-plugin' }
            jcenter()
            mavenCentral()
        }
    }
}

导入工程,修改gradle对应的jdk版本

image

设置工程jdk

image


image

Build

image


由于一开始设置过gradle依赖的全局加速,所以从阿里云拉取依赖

image


依赖下载完毕

image


分别执行

image


image

创建测试代码

在spring-test新建包study

  • TestServiceImpl.java
package org.springframework.test.study;

import org.springframework.stereotype.Component;

@Component
public class TestServiceImpl {
	public void hello() {
		System.out.println("hello");
	}
}

  • TestSpring.java
package org.springframework.test.study;

import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

public class TestSpring {
	public static void main(String[] args) {
		ApplicationContext context = new AnnotationConfigApplicationContext("org.springframework.test.study");
		context.getBean(TestServiceImpl.class).hello();
	}
}

运行main,执行结果如下:

image

posted on 2023-07-17 20:32  ngu2020  阅读(77)  评论(0编辑  收藏  举报