我在 Grails 4.0.8 (Windows 10)(Java 11) 中创建一个项目 添加所有依赖项后,我收到此错误。
java.io.IOException: The filename or extension is too long
我搜索了整个 StackOverflow 并尝试使用解决方案,但没有一个有效。
所有导致此错误消息。
Execution failed for task ':bootRun'.
> Main class name has not been configured and it could not be resolved
另外,我在 build.gradle 中有一些依赖项,其中一些在 /libs 作为 *.jar
目前我的 build.gradle 看起来像这样(应用了解决方案)我做了什么,因为解决方案写在注释中,因为下面的 //_____ 是解决方案的一部分
buildscript {
repositories {
maven { url "http://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "gradle.plugin.com.github.erdi.webdriver-binaries:webdriver-binaries-gradle-plugin:2.0"
classpath "org.grails.plugins:hibernate5:7.0.4"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:3.2.4"
// classpath group: 'org.apache.poi', name: 'poi-ooxml-schemas', version: '4.1.2'
// classpath group: 'org.apache.poi', name: 'poi', version: '4.1.2'
// classpath group: 'org.apache.poi', name: 'poi-ooxml', version: '4.1.2'
}
}
version "0.1"
group "com.main.projectname"
apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"com.github.erdi.webdriver-binaries"
apply plugin:"com.bertramlabs.asset-pipeline"
apply plugin:"org.grails.grails-gsp"
repositories {
mavenCentral()
maven { url "http://repo.grails.org/grails/core" }
maven {url "http://tools-artifactory.tetris.ideasdev.int:82/artifactory/repo"}
//for external-config
maven { url "https://oss.jfrog.org/repo/" }
}
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
dependencies {
developmentOnly("org.springframework.boot:spring-boot-devtools")
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core:4.0.8"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-web-boot"
compile "org.grails:grails-logging"
compile "org.grails:grails-plugin-rest"
compile "org.grails:grails-plugin-databinding"
compile "org.grails:grails-plugin-i18n"
compile "org.grails:grails-plugin-services"
compile "org.grails:grails-plugin-url-mappings"
compile "org.grails:grails-plugin-interceptors"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:async"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:events"
compile "org.grails.plugins:hibernate5"
compile "org.hibernate:hibernate-core"
compile "org.grails.plugins:gsp"
compileOnly "io.micronaut:micronaut-inject-groovy"
console "org.grails:grails-console"
profile "org.grails.profiles:web"
runtime "org.glassfish.web:el-impl:2.1.2-b03"
runtime "com.h2database:h2:1.4.199"
runtime "org.apache.tomcat:tomcat-jdbc"
runtime "javax.xml.bind:jaxb-api:2.3.1"
runtime "com.bertramlabs.plugins:asset-pipeline-grails"
testCompile "io.micronaut:micronaut-inject-groovy"
testCompile "org.grails:grails-gorm-testing-support"
testCompile "org.mockito:mockito-core"
testCompile "org.grails:grails-web-testing-support"
testCompile "org.grails.plugins:geb"
testCompile "org.seleniumhq.selenium:selenium-remote-driver"
testCompile "org.seleniumhq.selenium:selenium-api:3.14.0"
testCompile "org.seleniumhq.selenium:selenium-support:3.14.0"
testRuntime "org.seleniumhq.selenium:selenium-chrome-driver:3.14.0"
testRuntime "org.seleniumhq.selenium:selenium-firefox-driver:3.14.0"
// User added
compile 'org.grails.plugins:external-config:2.0.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.grails.plugins:grails-shiro:3.3'
// implementation group: 'com.github.ManifestClasspath', name: 'com.github.ManifestClasspath.gradle.plugin', version: '0.1.0-RELEASE', ext: 'pom'
implementation group: 'org.grails.plugins', name: 'quartz', version: '2.0.13'
implementation group: 'org.springframework', name: 'spring-jms', version: '5.3.4'
implementation group: 'commons-dbcp', name: 'commons-dbcp', version: '1.4'
implementation group: 'commons-io', name: 'commons-io', version: '2.8.0'
implementation group: 'org.springframework', name: 'spring-context-support', version: '3.2.18.RELEASE'
implementation "opensymphony:quartz-all:1.6.3"
// implementation group: 'org.quartz-scheduler', name: 'quartz', version: '2.3.2'
implementation group: 'org.apache.poi', name: 'poi-ooxml-schemas', version: '4.1.2'
implementation group: 'org.apache.poi', name: 'poi', version: '4.1.2'
implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '4.1.2'
runtime group: 'org.apache.poi', name: 'poi-ooxml-schemas', version: '4.1.2'
runtime group: 'org.apache.poi', name: 'poi', version: '4.1.2'
runtime group: 'org.apache.poi', name: 'poi-ooxml', version: '4.1.2'
// implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.23'
//Depencencies from /lib found directly from maven
// implementation group: 'org.hibernate', name: 'hibernate-entitymanager', version: '5.2.1.Final'
// implementation group: 'com.microsoft.sqlserver', name: 'sqljdbc4', version: '4.2.6225.100'
// implementation group: 'commons-codec', name: 'commons-codec', version: '1.2' //1.15
// implementation group: 'javax.activation', name: 'activation', version: '1.1' //1.1.1
// implementation group: 'org.apache.axis', name: 'axis', version: '1.4'
// implementation group: 'org.apache.commons', name: 'commons-collections4', version: '4.1'//4.4
}
//Task below is part of solution
task pathingJar(type: Jar) {
dependsOn configurations.runtime
appendix = 'pathing'
doFirst {
manifest {
attributes "Class-Path": configurations.runtime.files.collect {
it.toURL().toString().replaceFirst(/file:\/+/, '/')
}.join(' ')
}
}
}
bootRun {
//Line below is part of solution
dependsOn pathingJar
ignoreExitValue true
jvmArgs(
'-Dspring.output.ansi.enabled=always',
'-noverify',
'-XX:TieredStopAtLevel=1',
'-Xmx1024m')
sourceResources sourceSets.main
String springProfilesActive = 'spring.profiles.active'
systemProperty springProfilesActive, System.getProperty(springProfilesActive)
//doFirst below is part of solution
doFirst {
classpath = files("$buildDir/classes/main", "$buildDir/resources/main", pathingJar.archivePath)
}
}
tasks.withType(GroovyCompile) {
configure(groovyOptions) {
forkOptions.jvmArgs = ['-Xmx1024m']
}
}
webdriverBinaries {
chromedriver '2.45.0'
geckodriver '0.24.0'
}
tasks.withType(Test) {
systemProperty "geb.env", System.getProperty('geb.env')
systemProperty "geb.build.reportsDir", reporting.file("geb/integrationTest")
systemProperty "webdriver.chrome.driver", System.getProperty('webdriver.chrome.driver')
systemProperty "webdriver.gecko.driver", System.getProperty('webdriver.gecko.driver')
}
assets {
minifyJs = true
minifyCss = true
}
//task pathingJar(type: Jar , dependsOn: 'cleanPathingJar') {
///**
// * If the gradle_user_home env var has been set to
// * C:\ on a Win7 machine, we may not have permission to write the jar to
// * this directory, so we will write it to the caches subdir instead.
// * This assumes a caches subdir containing the jars
// * will always exist.
// */
// gradleUserHome = new File(gradle.getGradleUserHomeDir(), "caches")
//
// relativeClasspathEntries = configurations.compile.files.collect {
// new File(gradleUserHome.getAbsolutePath()).toURI().
// relativize(new File(it.getAbsolutePath()).toURI()).getPath()
// }
// appendix = "pathing"
// destinationDir = gradleUserHome
// doFirst {
// manifest {
// attributes "Class-Path": relativeClasspathEntries.join(" ")
// }
// }
//}
//
//compileGroovy {
// dependsOn(pathingJar)
// classpath = files(pathingJar.archivePath)
//}
我原来的 build.gradle 如下:
buildscript {
repositories {
maven { url "http://repo.grails.org/grails/core" }
}
dependencies {
classpath "org.grails:grails-gradle-plugin:$grailsVersion"
classpath "gradle.plugin.com.github.erdi.webdriver-binaries:webdriver-binaries-gradle-plugin:2.0"
classpath "org.grails.plugins:hibernate5:7.0.4"
classpath "com.bertramlabs.plugins:asset-pipeline-gradle:3.2.4"
// classpath group: 'org.apache.poi', name: 'poi-ooxml-schemas', version: '4.1.2'
// classpath group: 'org.apache.poi', name: 'poi', version: '4.1.2'
// classpath group: 'org.apache.poi', name: 'poi-ooxml', version: '4.1.2'
}
}
version "0.1"
group "com.main.projectname"
apply plugin:"eclipse"
apply plugin:"idea"
apply plugin:"war"
apply plugin:"org.grails.grails-web"
apply plugin:"com.github.erdi.webdriver-binaries"
apply plugin:"com.bertramlabs.asset-pipeline"
apply plugin:"org.grails.grails-gsp"
repositories {
mavenCentral()
maven { url "http://repo.grails.org/grails/core" }
maven {url "http://tools-artifactory.tetris.ideasdev.int:82/artifactory/repo"}
//for external-config
maven { url "https://oss.jfrog.org/repo/" }
}
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
dependencies {
developmentOnly("org.springframework.boot:spring-boot-devtools")
compile "org.springframework.boot:spring-boot-starter-logging"
compile "org.springframework.boot:spring-boot-autoconfigure"
compile "org.grails:grails-core:4.0.8"
compile "org.springframework.boot:spring-boot-starter-actuator"
compile "org.springframework.boot:spring-boot-starter-tomcat"
compile "org.grails:grails-web-boot"
compile "org.grails:grails-logging"
compile "org.grails:grails-plugin-rest"
compile "org.grails:grails-plugin-databinding"
compile "org.grails:grails-plugin-i18n"
compile "org.grails:grails-plugin-services"
compile "org.grails:grails-plugin-url-mappings"
compile "org.grails:grails-plugin-interceptors"
compile "org.grails.plugins:cache"
compile "org.grails.plugins:async"
compile "org.grails.plugins:scaffolding"
compile "org.grails.plugins:events"
compile "org.grails.plugins:hibernate5"
compile "org.hibernate:hibernate-core"
compile "org.grails.plugins:gsp"
compileOnly "io.micronaut:micronaut-inject-groovy"
console "org.grails:grails-console"
profile "org.grails.profiles:web"
runtime "org.glassfish.web:el-impl:2.1.2-b03"
runtime "com.h2database:h2:1.4.199"
runtime "org.apache.tomcat:tomcat-jdbc"
runtime "javax.xml.bind:jaxb-api:2.3.1"
runtime "com.bertramlabs.plugins:asset-pipeline-grails"
testCompile "io.micronaut:micronaut-inject-groovy"
testCompile "org.grails:grails-gorm-testing-support"
testCompile "org.mockito:mockito-core"
testCompile "org.grails:grails-web-testing-support"
testCompile "org.grails.plugins:geb"
testCompile "org.seleniumhq.selenium:selenium-remote-driver"
testCompile "org.seleniumhq.selenium:selenium-api:3.14.0"
testCompile "org.seleniumhq.selenium:selenium-support:3.14.0"
testRuntime "org.seleniumhq.selenium:selenium-chrome-driver:3.14.0"
testRuntime "org.seleniumhq.selenium:selenium-firefox-driver:3.14.0"
// User added
compile 'org.grails.plugins:external-config:2.0.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
compile 'org.grails.plugins:grails-shiro:3.3'
// implementation group: 'com.github.ManifestClasspath', name: 'com.github.ManifestClasspath.gradle.plugin', version: '0.1.0-RELEASE', ext: 'pom'
implementation group: 'org.grails.plugins', name: 'quartz', version: '2.0.13'
implementation group: 'org.springframework', name: 'spring-jms', version: '5.3.4'
implementation group: 'commons-dbcp', name: 'commons-dbcp', version: '1.4'
implementation group: 'commons-io', name: 'commons-io', version: '2.8.0'
implementation group: 'org.springframework', name: 'spring-context-support', version: '3.2.18.RELEASE'
implementation "opensymphony:quartz-all:1.6.3"
// implementation group: 'org.quartz-scheduler', name: 'quartz', version: '2.3.2'
implementation group: 'org.apache.poi', name: 'poi-ooxml-schemas', version: '4.1.2'
implementation group: 'org.apache.poi', name: 'poi', version: '4.1.2'
implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '4.1.2'
runtime group: 'org.apache.poi', name: 'poi-ooxml-schemas', version: '4.1.2'
runtime group: 'org.apache.poi', name: 'poi', version: '4.1.2'
runtime group: 'org.apache.poi', name: 'poi-ooxml', version: '4.1.2'
// implementation group: 'mysql', name: 'mysql-connector-java', version: '8.0.23'
//Depencencies from /lib found directly from maven
// implementation group: 'org.hibernate', name: 'hibernate-entitymanager', version: '5.2.1.Final'
// implementation group: 'com.microsoft.sqlserver', name: 'sqljdbc4', version: '4.2.6225.100'
// implementation group: 'commons-codec', name: 'commons-codec', version: '1.2' //1.15
// implementation group: 'javax.activation', name: 'activation', version: '1.1' //1.1.1
// implementation group: 'org.apache.axis', name: 'axis', version: '1.4'
// implementation group: 'org.apache.commons', name: 'commons-collections4', version: '4.1'//4.4
}
bootRun {
ignoreExitValue true
jvmArgs(
'-Dspring.output.ansi.enabled=always',
'-noverify',
'-XX:TieredStopAtLevel=1',
'-Xmx1024m')
sourceResources sourceSets.main
String springProfilesActive = 'spring.profiles.active'
systemProperty springProfilesActive, System.getProperty(springProfilesActive)
}
tasks.withType(GroovyCompile) {
configure(groovyOptions) {
forkOptions.jvmArgs = ['-Xmx1024m']
}
}
webdriverBinaries {
chromedriver '2.45.0'
geckodriver '0.24.0'
}
tasks.withType(Test) {
systemProperty "geb.env", System.getProperty('geb.env')
systemProperty "geb.build.reportsDir", reporting.file("geb/integrationTest")
systemProperty "webdriver.chrome.driver", System.getProperty('webdriver.chrome.driver')
systemProperty "webdriver.gecko.driver", System.getProperty('webdriver.gecko.driver')
}
assets {
minifyJs = true
minifyCss = true
}
//task pathingJar(type: Jar , dependsOn: 'cleanPathingJar') {
///**
// * If the gradle_user_home env var has been set to
// * C:\ on a Win7 machine, we may not have permission to write the jar to
// * this directory, so we will write it to the caches subdir instead.
// * This assumes a caches subdir containing the jars
// * will always exist.
// */
// gradleUserHome = new File(gradle.getGradleUserHomeDir(), "caches")
//
// relativeClasspathEntries = configurations.compile.files.collect {
// new File(gradleUserHome.getAbsolutePath()).toURI().
// relativize(new File(it.getAbsolutePath()).toURI()).getPath()
// }
// appendix = "pathing"
// destinationDir = gradleUserHome
// doFirst {
// manifest {
// attributes "Class-Path": relativeClasspathEntries.join(" ")
// }
// }
//}
//
//compileGroovy {
// dependsOn(pathingJar)
// classpath = files(pathingJar.archivePath)
//}
我尝试了以下解决方案,但没有一个有效或导致顶部提到的相同主类未配置错误
buildscript {
dependencies {
classpath "com.github.viswaramamoorthy:gradle-util-plugins:0.1.0-RELEASE"
}
}
...
apply plugin: 'ManifestClasspath'
plugins {
id 'org.springframework.boot' version '2.1.4.RELEASE'
id 'java'
id "com.github.ManifestClasspath" version "0.1.0-RELEASE"
}
apply plugin: 'io.spring.dependency-management'
apply plugin: 'application'
mainClassName = 'com.example.demo.Application'
dependencies {
}