我有一个迁移到Sping Boot 3.1.0和Java 17的应用程序。现在我正试图让它与Spring 6.0.9一起工作(在此之前,正如您可能在注解的依赖项中看到的那样,它已经显式地降级了Spring版本,因为版本升级的历史记录。
所以,当我尝试运行bootRun
第四次配置时,
buildscript {
ext {
springBootVersion = '3.1.0'
}
repositories {
maven {
url "https://nexus.dev.domoy.ru/repository/mvn-remote/"
}
maven {
url "https://nexus.dev.domoy.ru/repository/gradle-remote-plugins/"
}
maven {
credentials {
username "$mavenUser"
password "$mavenPassword"
}
url "$mavenUrl"
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.7.1"
classpath "gradle.plugin.com.github.viswaramamoorthy:gradle-util-plugins:0.1.0-RELEASE"
}
}
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'org.sonarqube'
apply plugin: 'jacoco'
apply plugin: 'com.github.ManifestClasspath'
group = 'rf.dom.billing'
archivesBaseName = 'billing-ap'
version = '1.0.5'
mainClassName = 'rf.dom.billing.ap.Application'
sourceCompatibility = 1.17
targetCompatibility = 1.17
repositories {
maven {
url "https://nexus.dev.domoy.ru/repository/mvn-remote/"
}
maven {
url "https://nexus.dev.domoy.ru/repository/gradle-remote-plugins/"
}
maven {
credentials {
username "$mavenUser"
password "$mavenPassword"
}
url "$mavenUrl"
}
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-starter-parent:Hoxton.SR10"
}
}
//sonarqube {
// properties {
// property "sonar.host.url", "https://sonarqube.domoy.ru/sonarqube"
// property "sonar.login", "83f2b4d2c20b87a6f96385bb947d3531dbd4ba8e"
// property "sonar.projectKey", "billing-ap"
// property "sonar.projectName", "BILLING-ap"
// property "sonar.exclusions", "**/dto/**/*.java"
// }
//}
jacoco {
toolVersion = "0.8.8"
}
bootRun {
systemProperties System.properties
systemProperties.remove("java.endorsed.dirs")
}
sourceSets {
main {
java {
srcDirs = ['src/main/java', 'src/generated/java']
}
}
}
configurations {
bouncyCastle
runtime.exclude group: "org.springframework.boot", module: "spring-boot-starter-tomcat"
compile.exclude group: "net.sf.ehcache"
all {
resolutionStrategy {
// Force jackson 2.4.4 for Spark
force 'com.fasterxml.jackson.core:jackson-core:2.13.5', 'com.fasterxml.jackson.core:jackson-databind:2.13.5', 'com.fasterxml.jackson.core:jackson-annotations:2.13.5'
}
}
}
task copyCoreJarsToLibs(type: Copy, dependsOn: jar) {
from "build/libs"
into "${rootDir}/artifacts/docker/billing_ap"
exclude '*.original', '*replicator*'
}
task copyDockerfiles(type: Copy) {
from "${rootDir}/dockerfile"
into "${rootDir}/artifacts/docker/billing_ap"
}
task copyDockerfilesProd(type: Copy) {
from "${rootDir}/dockerfile/Dockerfile-prod"
into "${rootDir}/artifacts/docker/billing_ap"
rename { String fileName ->
fileName.replace("Dockerfile-prod",
"Dockerfile")
}
}
task collectArtifacts {
dependsOn(build, copyCoreJarsToLibs, copyDockerfiles)
}
task collectArtifactsProd {
dependsOn(build, copyCoreJarsToLibs, copyDockerfilesProd)
}
ext['elasticsearch.version'] = '7.2.0'
dependencies {
implementation 'javax.validation:validation-api:2.0.1.Final'
implementation "org.springframework.boot:spring-boot-starter:${springBootVersion}"
implementation "org.springframework.boot:spring-boot-starter-web:${springBootVersion}"
implementation "org.springframework.boot:spring-boot-starter-webflux:${springBootVersion}"
implementation "org.springframework.boot:spring-boot-starter-data-rest:${springBootVersion}"
implementation "org.springframework.boot:spring-boot-starter-mail:${springBootVersion}"
implementation "org.springframework.boot:spring-boot-starter-oauth2-client:${springBootVersion}"
implementation "org.springframework.boot:spring-boot-starter-oauth2-resource-server:${springBootVersion}"
implementation("org.springframework.boot:spring-boot-starter-data-jpa:${springBootVersion}") {
// exclude group: 'org.hibernate', module: 'hibernate-entitymanager'
}
implementation "org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}"
//implementation "org.springframework.boot:spring-boot-actuator-autoconfigure:${springBootVersion}"
//implementation "org.springframework.boot:spring-boot-autoconfigure:${springBootVersion}"
runtime 'io.micrometer:micrometer-registry-prometheus'
// implementation 'org.springframework.amqp:spring-amqp:2.3.11'
// implementation 'org.springframework.boot:spring-boot-starter-undertow'
// implementation 'org.springframework.boot:spring-boot-starter-oauth2-resource-server'
// implementation 'org.springframework.security:spring-security-oauth2-jose:5.5.7'
// implementation 'org.springframework.security:spring-security-oauth2-core:5.5.7'
// implementation 'org.springframework.security:spring-security-core:5.5.7'
// implementation 'org.springframework.security:spring-security-web:5.5.7'
// implementation 'org.springframework.security:spring-security-oauth2-client:5.7.5'
// implementation 'org.springframework.security:spring-security-oauth2-resource-server:5.5.7'
// implementation 'org.springframework:spring-core:6.0.9'
// implementation 'org.springframework:spring-beans:6.0.9'
// implementation 'org.springframework:spring-expression:6.0.9'
// implementation 'org.springframework:spring-webflux:6.0.9'
// implementation 'org.springframework:spring-webmvc:6.0.9'
// implementation 'org.springframework:spring-web:6.0.9'
implementation 'io.projectreactor:reactor-core:3.2.12.RELEASE'
compileOnly 'org.projectlombok:lombok:1.18.22+'
annotationProcessor 'org.projectlombok:lombok:1.18.22+'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22+'
annotationProcessor 'org.hibernate:hibernate-jpamodelgen:5.4.4.Final'
implementation 'org.postgresql:postgresql:42.2.8'
implementation 'com.zaxxer:HikariCP:3.4.0'
//implementation 'org.flywaydb:flyway-core:5.2.4'
implementation 'org.hibernate.javax.persistence:hibernate-jpa-2.2-api:1.0.0.Beta2'
implementation 'net.bull.javamelody:javamelody-spring-boot-starter:1.79.0'
implementation 'commons-io:commons-io:2.6'
implementation 'io.springfox:springfox-swagger2:3.0.0'
//
// {
// exclude module: 'swagger-annotations'
// exclude module: 'swagger-models'
// }
//implementation 'io.swagger:swagger-annotations:1.5.23'
//implementation 'io.swagger:swagger-models:1.5.23'
implementation 'io.springfox:springfox-swagger-ui:3.0.0'
implementation 'rf.dom.billing:billing-model:RELEASE.2.2.49'
implementation ('rf.dom.billing:billing-common:RELEASE.1.0.6')
{
exclude group: 'bouncycastle', module: 'bcprov-jdk14'
}
implementation 'rf.dom.billing:billing-tracking:RELEASE.1.1.13'
implementation 'rf.dom.billing:billing-docstore-integration:1.0.3'
/*Cloud start*/
implementation 'org.springframework.cloud:spring-cloud-starter-config:2.1+'
implementation 'org.springframework.cloud:spring-cloud-starter:2.1+'
implementation 'org.springframework.cloud:spring-cloud-config-client:2.1+'
/*Cloud end*/
implementation 'org.jxls:jxls-poi:1.2.0'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.boot:spring-boot-starter-undertow'
testImplementation 'org.testng:testng:6.14.3'
testImplementation 'org.powermock:powermock-api-mockito2:2.0.2'
testImplementation 'com.opentable.components:otj-pg-embedded:0.13.1'
testImplementation 'org.flywaydb:flyway-core:5.2.4'
//trivy
// implementation 'ch.qos.logback:logback-core:1.2.9'
// implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.5'
// implementation 'com.fasterxml.jackson.core:jackson-core:2.13.5'
// implementation 'com.fasterxml.jackson.core:jackson-annotations:2.13.5'
// implementation 'com.google.guava:guava:30.0-jre'
// //implementation 'com.nimbusds:nimbus-jose-jwt:7.9'
// implementation 'com.nimbusds:nimbus-jose-jwt:8.21'
// implementation 'com.nimbusds:oauth2-oidc-sdk:9.19'
// implementation 'commons-io:commons-io:2.7'
//
// implementation 'io.netty:netty-codec:4.1.77.Final'
// implementation 'io.netty:netty-codec-http:4.1.77.Final'
// implementation 'io.netty:netty-codec-http2:4.1.77.Final'
// implementation 'io.netty:netty-codec-socks:4.1.77.Final'
// implementation 'io.netty:netty-handler:4.1.77.Final'
////
// implementation 'io.undertow:undertow-core:2.2.19.Final'
// implementation 'net.minidev:json-smart:2.4.9'
// implementation 'org.apache.commons:commons-compress:1.21'
// implementation 'org.apache.httpcomponents:httpclient:4.5.13'
// implementation 'org.apache.poi:poi:5.2.1'
// implementation 'org.apache.poi:poi-ooxml:5.2.1'
// implementation 'org.bouncycastle:bcprov-jdk14:1.73'
// //implementation 'bouncycastle:bcprov-jdk14:161'
// //implementation 'bouncycastle:bcprov-jdk14:161'
// implementation 'org.bouncycastle:bcprov-jdk15on:1.67'
// implementation 'org.elasticsearch:elasticsearch:7.9.2'
// implementation 'org.elasticsearch.client:elasticsearch-rest-client:7.9.2'
// implementation 'org.elasticsearch.client:elasticsearch-rest-high-level-client:7.9.2'
// implementation 'org.eclipse.jetty:jetty-util:11.0.15'
//// implementation 'org.dom4j:dom4j:2.1.3'
// implementation 'org.eclipse.jetty:jetty-http:11.0.15'
// implementation 'org.eclipse.jetty:jetty-io:11.0.15'
// implementation 'org.hibernate.validator:hibernate-validator:6.0.20.Final'
// implementation 'org.postgresql:postgresql:42.5.1'
// implementation 'org.yaml:snakeyaml:1.33'
// implementation 'com.fasterxml.jackson.core:jackson-databind:2.15.0'
// implementation 'org.apache.tomcat.embed:tomcat-embed-core:9.0.69'
bouncyCastle 'org.bouncycastle:bcprov-jdk14:1.73'
compileOnly 'jakarta.servlet:jakarta.servlet-api:6.0.0'
}
task installBouncyCastleJar {
doLast {
def bcFile = file('build/libs/bcprov-jdk14-1.73.jar')
def groupId = 'bouncycastle'
def artifactId = 'bcprov-jdk14'
def version = '173'
def packaging = 'jar'
// project.repositories.maven.install([
// file: bcFile,
// groupId: groupId,
// artifactId: artifactId,
// version: version,
// packaging: packaging
// ])
}
}
project.afterEvaluate {
build.dependsOn(installBouncyCastleJar)
}
tasks.withType(JavaCompile) {
options.annotationProcessorGeneratedSourcesDirectory = file("src/generated/java")
}
wrapper {
distributionType = Wrapper.DistributionType.ALL
gradleVersion = '6.0'
}
test {
// enable TestNG support (default is JUnit)
useTestNG()
testLogging.showStandardStreams = true
testLogging.exceptionFormat = 'full'
}
task printName {
doLast {
print project.name
}
}
task printVersion {
doLast {
print project.version
}
}
我得到下面的问题,而应用程序是在17日卡瓦,gradle是在17日运行的Java和没有什么可能需要上述Java版本?
2023-06-12 18:36:20.466 [main] WARN o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [D:\Java\domrf2\build\classes\java\main\rf\dom\billing\ap\Application.class]; nested exception is org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [D:\Java\domrf2\build\classes\java\main\rf\dom\billing\ap\Application.class]; nested exception is java.lang.IllegalArgumentException: Unsupported class file major version 61
2023-06-12 18:36:20.475 [main] ERROR o.s.boot.SpringApplication - Application run failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [D:\Java\domrf2\build\classes\java\main\rf\dom\billing\ap\Application.class]; nested exception is org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [D:\Java\domrf2\build\classes\java\main\rf\dom\billing\ap\Application.class]; nested exception is java.lang.IllegalArgumentException: Unsupported class file major version 61
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:452)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(ClassPathScanningCandidateComponentProvider.java:315)
at org.springframework.context.annotation.ClassPathBeanDefinitionScanner.doScan(ClassPathBeanDefinitionScanner.java:276)
at org.springframework.context.annotation.ComponentScanAnnotationParser.parse(ComponentScanAnnotationParser.java:132)
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:296)
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:250)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:207)
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:175)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:319)
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:280)
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:96)
at
org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:707)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:533)
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750)
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226)
at rf.dom.billing.ap.Application.main(Application.java:24)
Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [D:\Java\domrf2\build\classes\java\main\rf\dom\billing\ap\Application.class]; nested exception is java.lang.IllegalArgumentException: Unsupported class file major version 61
Caused by: org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet: file [D:\Java\domrf2\build\classes\java\main\rf\dom\billing\ap\Application.class]; nested exception is java.lang.IllegalArgumentException: Unsupported class file major version 61
at org.springframework.core.type.classreading.SimpleMetadataReader.getClassReader(SimpleMetadataReader.java:60)
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:49)
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103)
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(CachingMetadataReaderFactory.java:123)
at org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.scanCandidateComponents(ClassPathScanningCandidateComponentProvider.java:429)
... 21 common frames omitted
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 61
at org.springframework.asm.ClassReader.<init>(ClassReader.java:196)
at org.springframework.asm.ClassReader.<init>(ClassReader.java:177)
at org.springframework.asm.ClassReader.<init>(ClassReader.java:163)
at org.springframework.asm.ClassReader.<init>(ClassReader.java:284)
at org.springframework.core.type.classreading.SimpleMetadataReader.getClassReader(SimpleMetadataReader.java:57)
... 25 common frames omitted
Caused by: java.lang.IllegalArgumentException: Unsupported class file major version 61
Execution failed for task ':bootRun'.
> Process 'command 'D:\Java\jdk-17.0.2\bin\java.exe'' finished with non-zero exit value 1
将ASM更新到9.5后,UPD仍然出现问题:
1条答案
按热度按时间41ik7eoe1#
您可能正在使用太旧版本的Java ASM。
根据versions列表,您至少需要9.1版本才能支持Java 17。
请参阅此SO问题的答案,以了解哪个依赖项正在使用过时的ASM版本:Using Gradle to find dependency tree
我还看到你指的是Gradle版本6,这也可能是一个问题。请尝试将其更新到更新的版本,因为Gradle本身也使用ASM。Gradle compatibility chart显示您至少需要版本7.3才能支持Java 17