码迷,mamicode.com
首页 > 编程语言 > 详细

intellij idea gradle 导入 spring 问题记录

时间:2019-12-23 13:42:00      阅读:590      评论:0      收藏:0      [点我收藏+]

标签:framework   extension   jdk   xsd   main   打开   image   rate   find   

环境:

  windows 7

  oracle jdk 1.8

  intellij idea 2019.3.1

  spring-framework 5.1.22.RELEASE

 

步骤:

1: 下载解压spring zip 包(githup或者gitee下载)

 

 

2: 修改spring-framework源码配置信息

打开项目子目录 >>> ./gradle

技术图片

 

 

 

修改docs.gradle文件 >>> dokka方法以及asciidoctor方法注释

技术图片

 

 

 技术图片

 

注: 

task schemaZip(type: Zip) 在某些版本该任务中是没有兼容window的路径符号,需要手动修改一下

技术图片

 

 

 修改如下  >>>>>>>

task schemaZip(type: Zip) {
    group = "Distribution"
    baseName = "spring-framework"
    classifier = "schema"
    description = "Builds -${classifier} archive containing all " +
            "XSDs for deployment at https://springframework.org/schema."
    duplicatesStrategy ‘exclude‘
    moduleProjects.each { subproject ->
        def Properties schemas = new Properties();

        subproject.sourceSets.main.resources.find {
            (it.path.endsWith("META-INF/spring.schemas") || it.path.endsWith("META-INF\\spring.schemas"))
        }?.withInputStream { schemas.load(it) }

        for (def key : schemas.keySet()) {
            def shortName = key.replaceAll(/http.*schema.(.*).spring-.*/, ‘$1‘)
            assert shortName != key
            File xsdFile = subproject.sourceSets.main.resources.find {
                (it.path.endsWith(schemas.get(key)) || it.path.endsWith(schemas.get(key).replaceAll(‘\\/‘,‘\\\\‘)))
            }
            assert xsdFile != null
            into (shortName) {
                from xsdFile.path
            }
        }
    }
}

 

 

 

先留一个坑 。。。。

 

 

 

 

 

 

 

 

3.导入项目 >>> 选中build.gradle右键import

 

漫长的等待中 。。。。

 

 

 

 

一般情况下导入是可以成功的,但 。。

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.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)
    
... ...

 

 

这个是因为spring配置的gradle版本问题

技术图片

 

 

 

 

打开./gradle/wrapper/gradle-wrapper.properties文件

修改为5.x版本,博主修改为gradle-5.5.1-all.zip //all包含源码

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

成功导入展示:

技术图片

 

 

 

 

4. 编译源代码

这里先看一下spring的markdown文档

技术图片

 

 

 大致意思是需要先预编译`spring-core`、`spring-oxm`以及`spring-aspects`。

 先直接编译`spring-oxm`它依赖了`spring-core`

 gradle窗口中选择spring-oxm > Tasks > other > compileTestJava

然后是`spring-aspects` >>>
spring-aspects > Tasks > other > compileTestJava

如果失败请先安装ajc编译器 https://www.eclipse.org/aspectj/downloads.php

技术图片

 

 点击Test 

技术图片

 

 

再生成即可

 

 

----------------------------------------------------------------------------------

目前遇到问题就这几点,希望能帮助到大家。

intellij idea gradle 导入 spring 问题记录

标签:framework   extension   jdk   xsd   main   打开   image   rate   find   

原文地址:https://www.cnblogs.com/bingco/p/12082955.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!