由于路径太长,无法在Windows上使用Kotlin bootRun /在META-INF / spring.factories

时间:2018-08-31 03:33:31

标签: java spring gradle kotlin bootrun

当我在Microsoft Windows [版本10.0.17134.228]上运行bootRun时,它会在'CreateProcess error=206' when classpath too long上引发错误cp,但是如果我运行{ java -jar meow.jar产生的广口瓶上的{1}}。

我尝试通过bootJar选项以及在REGEDIT中启用长路径,然后重新启动计算机,但是没有运气。

这是长时间使用bootRun的典型Java项目的常见问题,如this github issue

所示

因此,我决定像在this github issue中那样编写自定义Enable NTFS long paths,但是遇到了另一个问题。

我的bootRun

版本版本:build.gradle

gradle-4.5.1-all.zip

引发错误:

buildscript {
    ext {
        kotlinVersion = '1.2.51'
        springBootVersion = '2.0.3.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
        classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}")
        classpath("org.jetbrains.kotlin:kotlin-allopen:${kotlinVersion}")
        classpath("org.jetbrains.kotlin:kotlin-stdlib:${kotlinVersion}")
        classpath('gradle.plugin.com.palantir.gradle.docker:gradle-docker:0.13.0')
    }
}

plugins {
    id "org.jlleitschuh.gradle.ktlint" version "4.1.0"
}

apply plugin: 'kotlin'
apply plugin: 'kotlin-spring'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'kotlin-kapt'


group = 'com.meow'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
compileKotlin {
    kotlinOptions {
        freeCompilerArgs = ["-Xjsr305=strict"]
        jvmTarget = "1.8"
    }
}
compileTestKotlin {
    kotlinOptions {
        freeCompilerArgs = ["-Xjsr305=strict"]
        jvmTarget = "1.8"
    }
}

repositories {
    mavenCentral()
    jcenter()
}


dependencies {
    compile 'org.springframework.boot:spring-boot-starter-web'
    compile 'org.springframework.security:spring-security-web'
    compile 'org.springframework.security:spring-security-config'
    compile 'org.springframework.security:spring-security-core'
    compile 'org.springframework.security:spring-security-test'
    compile 'org.springframework.data:spring-data-redis'
    compile 'com.fasterxml.jackson.module:jackson-module-kotlin'
    compile 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
    compile 'org.jetbrains.kotlin:kotlin-reflect'
    compile 'com.github.kittinunf.fuel:fuel:1.13.0'
    compile 'io.github.microutils:kotlin-logging:1.5.4'
    compile 'redis.clients:jedis'
    compile 'org.apache.poi:poi-ooxml:3.16'
    compile "com.fasterxml.jackson.module:jackson-module-kotlin:2.9.+"
    compile "javax.xml.bind:jaxb-api"
    compile group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.11.390'


    runtime 'org.springframework.boot:spring-boot-devtools'

    testCompile 'org.springframework.boot:spring-boot-starter-test'
}

ktlint {
    verbose = true
    // For now have to be uppercase, see https://github.com/gradle/gradle/issues/4030
    reporters = ["CHECKSTYLE", "PLAIN"]
}

apply plugin: 'com.palantir.docker'

group = 'meow'

springBoot {
    mainClassName = 'com.meow.ApplicationKt'
}

docker {
    dependsOn build
    name "${project.group}/${bootJar.baseName}"
    files bootJar.archivePath
    buildArgs(['JAR_FILE': "${bootJar.archiveName}"])
}

task pathingJar(type: Jar) {
    dependsOn configurations.runtime
    appendix = 'pathing'
    zip64 true
    doFirst {
        manifest {
            attributes "Class-Path": configurations.runtime.files.collect {
                it.toURL().toString().replaceFirst('/file:/+/', '/')
            }.join(' ')
        }
    }
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}

sourceSets {
    main.java.srcDirs += 'src/main/kotlin/'
    test.java.srcDirs += 'src/test/kotlin/'
}

bootRun {
    dependsOn pathingJar
    main = 'com.meow.ApplicationKt'
    sourceResources sourceSets.main
    doFirst {
        classpath = files(sourceSets.main.output.files, pathingJar.archivePath)
    }
}

运行Aug. 31, 2018 1:13:03 PM com.meow.ApplicationKt logStarting INFO: Starting ApplicationKt on CREAMPUFF with PID 13120 (C:\Neila\Projects\meow\fan\build\classes\kotlin\main started by Sam Xia in C:\Neila\Projects\meow\fan) Aug. 31, 2018 1:13:03 PM com.meow.ApplicationKt logStartupProfileInfo INFO: No active profile set, falling back to default profiles: default Aug. 31, 2018 1:13:03 PM org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext prepareRefresh INFO: Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@7c6908d7: startup date [Fri Aug 31 13:13:03 AEST 2018]; root of context hierarchy Aug. 31, 2018 1:13:04 PM org.springframework.boot.SpringApplication reportFailure SEVERE: Application run failed java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct. at org.springframework.util.Assert.notEmpty(Assert.java:450) at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getCandidateConfigurations(AutoConfigurationImportSelector.java:160) at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.selectImports(AutoConfigurationImportSelector.java:96) at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector$AutoConfigurationGroup.process(AutoConfigurationImportSelector.java:386) at org.springframework.context.annotation.ConfigurationClassParser$DeferredImportSelectorGrouping.getImports(ConfigurationClassParser.java:830) at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:563) at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:188) at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:316) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:273) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:93) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) at com.meow.ApplicationKt.main(Application.kt:13) Aug. 31, 2018 1:13:04 PM org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext doClose INFO: Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@7c6908d7: startup date [Fri Aug 31 13:13:03 AEST 2018]; root of context hierarchy :bootRun FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':bootRun'. > Process 'command 'C:\Program Files\Java\jdk-10.0.1\bin\java.exe'' finished with non-zero exit value 1 的朋友的jar中没有bootRun,我认为这应该由插件提供吗?

在每次运行spring.factories之前,我都尝试过./gradlew clean

感谢您抽出宝贵的时间阅读我的问题,我们将不胜感激!

0 个答案:

没有答案