spring构建

1.找到github地址

https://github.com/spring-projects/spring-framework/tree/v5.3.5
https://github.com/spring-projects/spring-boot/tree/v2.4.4

2.复制到gitee里面,弄成自己的仓库

image.png

3.用git命令行工具

git clone https://gitee.com/wisper_wind/spring-framework.git
git clone https://gitee.com/wisper_wind/spring-boot.git

4.使用命令行执行gradlew

cmd进入spring-framework目录,执行命令gradlew build
image.png

5.idea打开

  1. Import into IntelliJ (File -> New -> Project from Existing Sources -> Navigate to directory -> Select build.gradle)
  2. 报错 ```shell Project resolve errorsD:\SpringProject\spring-framework\build.gradleroot project ‘spring’: Unable to resolve additional project configuration.Details: java.lang.IllegalStateException: Resolving dependency configuration ‘testFixturesCompileOnly’ is not allowed as it is defined as ‘canBeResolved=false’.Instead, a resolvable (‘canBeResolved=true’) dependency configuration that extends ‘testFixturesCompileOnly’ should be resolved.

exception during working with external system: java.lang.AssertionError at org.jetbrains.plugins.gradle.service.project.BaseGradleProjectResolverExtension.createModule(BaseGradleProjectResolverExtension.java:154) at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86) at org.jetbrains.kotlin.idea.configuration.KotlinMPPGradleProjectResolver.createModule(KotlinMPPGradleProjectResolver.kt:67) at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86) at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86) at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86) at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86) at com.android.tools.idea.gradle.project.sync.idea.AndroidGradleProjectResolver.createModule(AndroidGradleProjectResolver.java:165) at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86) at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86) at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86) at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86) at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86) at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86) at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86) at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86) at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86) at org.jetbrains.kotlin.android.configure.KotlinAndroidMPPGradleProjectResolver.createModule(KotlinAndroidMPPGradleProjectResolver.kt:45) at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86) at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86) at org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension.createModule(AbstractProjectResolverExtension.java:86) at org.jetbrains.plugins.gradle.service.project.TracedProjectResolverExtension.createModule(TracedProjectResolverExtension.java:45) at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.doResolveProjectInfo(GradleProjectResolver.java:344) at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.access$200(GradleProjectResolver.java:60) at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:725) at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver$ProjectConnectionDataNodeFunction.fun(GradleProjectResolver.java:708) at org.jetbrains.plugins.gradle.service.execution.GradleExecutionHelper.execute(GradleExecutionHelper.java:276) at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:125) at org.jetbrains.plugins.gradle.service.project.GradleProjectResolver.resolveProjectInfo(GradleProjectResolver.java:60) at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.lambda$resolveProjectInfo$0(RemoteExternalSystemProjectResolverImpl.java:35) at com.intellij.openapi.externalSystem.service.remote.AbstractRemoteExternalSystemService.execute(AbstractRemoteExternalSystemService.java:57) at com.intellij.openapi.externalSystem.service.remote.RemoteExternalSystemProjectResolverImpl.resolveProjectInfo(RemoteExternalSystemProjectResolverImpl.java:35) at com.intellij.openapi.externalSystem.service.remote.wrapper.ExternalSystemProjectResolverWrapper.resolveProjectInfo(ExternalSystemProjectResolverWrapper.java:44) at com.intellij.openapi.externalSystem.service.internal.ExternalSystemResolveProjectTask.doExecute(ExternalSystemResolveProjectTask.java:100) at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:146) at com.intellij.openapi.externalSystem.service.internal.AbstractExternalSystemTask.execute(AbstractExternalSystemTask.java:132) at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.executeImpl(ExternalSystemUtil.java:540) at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.lambda$execute$1(ExternalSystemUtil.java:392) at com.intellij.openapi.project.DumbServiceImpl.suspendIndexingAndRun(DumbServiceImpl.java:150) at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$3.execute(ExternalSystemUtil.java:392) at com.intellij.openapi.externalSystem.util.ExternalSystemUtil$5.run(ExternalSystemUtil.java:647) at com.intellij.openapi.progress.impl.CoreProgressManager$TaskRunnable.run(CoreProgressManager.java:888) at com.intellij.openapi.progress.impl.CoreProgressManager.lambda$runProcess$2(CoreProgressManager.java:163) at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:585) at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:531) at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:59) at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:150) at com.intellij.openapi.progress.impl.CoreProgressManager$4.lambda$run$0(CoreProgressManager.java:402) at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:221) at com.intellij.openapi.progress.impl.CoreProgressManager$4.run(CoreProgressManager.java:402) at com.intellij.openapi.application.impl.ApplicationImpl$1.run(ApplicationImpl.java:238) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:834)

  1. <a name="pja9m"></a>
  2. ## 6.解决问题
  3. 报错里面出现了idea,全网搜索的方法都不行,参观[官网的构建文档](https://github.com/spring-projects/spring-framework/wiki/Build-from-Source)<br />官网的命令行build是可以的,idea的build会报错,可能是idea版本和spring构建gradle冲突导致的,回到idea里面,切换spring的版本到5.2.x(原先是最新的5.3.5)<br />![image.png](https://cdn.nlark.com/yuque/0/2021/png/655064/1618294845479-64634b32-c44a-4142-824d-f7dd9187d569.png#align=left&display=inline&height=339&margin=%5Bobject%20Object%5D&name=image.png&originHeight=678&originWidth=246&size=27693&status=done&style=none&width=123) <br />查看gradle.properties里面是:version=5.2.14.BUILD-SNAPSHOT,网上说最好用稳定的RELEASE.这边没注意
  4. 继续<br />gradlew build<br />gradlew :spring-oxm:compileTestJava<br />都是成功<br />然后用idea打开就可以了
  5. <a name="buD5k"></a>
  6. ## 7.测试
  7. ![image.png](https://cdn.nlark.com/yuque/0/2021/png/655064/1618295114941-6976e4b1-9ed9-4c8b-be0e-4a886f8309d3.png#align=left&display=inline&height=327&margin=%5Bobject%20Object%5D&name=image.png&originHeight=653&originWidth=370&size=26217&status=done&style=none&width=185)<br />1.新建module<br />2.添加依赖
  8. ```bash
  9. plugins {
  10. id 'java'
  11. }
  12. group 'org.springframework'
  13. version '5.2.14.BUILD-SNAPSHOT'
  14. sourceCompatibility = 1.8
  15. repositories {
  16. mavenCentral()
  17. }
  18. dependencies {
  19. compile(project(':spring-context'))
  20. testCompile group: 'junit', name: 'junit', version: '4.12'
  21. }

3.写一些代码
4.运行

  1. public class Demo01 {
  2. public static void main(String[] args) {
  3. AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(MyConfig.class);
  4. Dog bean = context.getBean(Dog.class);
  5. System.out.println(bean);
  6. }
  7. }

成功!

  1. > Task :leo-test-01:Demo01.main()
  2. 四月 13, 2021 2:07:50 下午 org.springframework.context.support.AbstractApplicationContext refresh
  3. 信息: diy spring
  4. Dog{name='ha'}
  5. BUILD SUCCESSFUL in 24s

springboot构建

git

类似的
先git clone然后
git checkout -b 2.4.0 v2.4.0
报错
Filename too long
error: The following untracked working tree files would be overwritten by checkout:
解决:
git config —global core.longpaths true
git clean -d -fx
git checkout -b 2.4.0 v2.4.0 成功

build

cmd:D:\SpringProject\spring-boot>gradlew build

  1. FAILURE: Build failed with an exception.
  2. * Where:
  3. Settings file 'D:\SpringProject\spring-boot\settings.gradle' line: 26
  4. * What went wrong:
  5. Error resolving plugin [id: 'io.spring.gradle-enterprise-conventions', version: '0.0.3']
  6. > Could not resolve all dependencies for configuration 'detachedConfiguration2'.
  7. > Could not determine artifacts for io.spring.gradle-enterprise-conventions:io.spring.gradle-enterprise-conventions.gradle.plugin:0.0.3
  8. > Could not get resource 'https://repo.spring.io/plugins-release/io/spring/gradle-enterprise-conventions/io.spring.gradle-enterprise-conventions.gradle.plugin/0.0.3/io.spring.gradle-enterprise-conventions.gradle.plugin-0.0.3.jar'.
  9. > Could not HEAD 'https://repo.spring.io/plugins-release/io/spring/gradle-enterprise-conventions/io.spring.gradle-enterprise-conventions.gradle.plugin/0.0.3/io.spring.gradle-enterprise-conventions.gradle.plugin-0.0.3.jar'. Received status code 401 from server: Unauthorized

去idea里面操作 修改build.gradle
image.png
修改setting.gradle
image.png
就可以正常build构建项目了,这一步比较慢

test

找到启动类
image.png
image.png
启动项目
image.png

debug

image.png