我有一个关于 Gretty 的项目。现在该项目正在准备部署到外部服务器。事实证明,在外部服务器上有一些古老版本的码头(比如,低于 9.4),它不适用于 JEP-238。而最新版本的 log4j 只是 JEP-238。当尝试在 jetty 上运行应用程序时,它会吐出一个众所周知的错误:
基本上有两种选择:
- 升级jetty版本,目前无法实现
- 省略 log4j 版本。
问题是,log4j 没有设置为显式依赖项,而是引入了其他一些依赖项。目前还不清楚是哪一个。这是 build.gradle:
plugins {
id 'java'
id 'war'
id "org.gretty" version "2.2.0"
}
group 'ru.example'
version '0.1'
sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = 'UTF-8'
ext {
SPRING_VERSION = '5.1.0.RELEASE'
JUNIT_VERSION = '5.3.1'
JACKSON_VERSION = '2.9.7'
LOMBOK_VERSION = '1.18.2'
}
repositories {
mavenCentral()
jcenter()
maven {
url 'https://oss.sonatype.org/content/repositories/releases/'
}
}
gretty {
springBootVersion = '2.0.5.RELEASE'
contextPath = "/"
}
dependencies {
// annotationProcessor group: 'org.projectlombok', name: 'lombok', version: LOMBOK_VERSION
compileOnly group: 'org.projectlombok', name: 'lombok', version: LOMBOK_VERSION
compileOnly group: 'com.google.appengine', name: 'appengine-endpoints-deps', version: '1.9.65'
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3'
compile group: 'org.springframework', name: 'spring-webmvc', version: SPRING_VERSION
compile group: 'org.springframework', name: 'spring-web', version: SPRING_VERSION
compile group: 'org.springframework', name: 'spring-jdbc', version: SPRING_VERSION
compile ("org.springframework.security:spring-security-web:4.1.0.RELEASE") {
exclude(module:'spring-web')
}
compile ("org.springframework.security:spring-security-config:4.1.0.RELEASE")
compile ("org.springframework.security:spring-security-ldap:4.1.0.RELEASE")
compile 'org.thymeleaf:thymeleaf-spring4:3.0.9.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: '2.0.5.RELEASE'
compile group: 'com.mchange', name: 'c3p0', version: '0.9.5.2'
compile group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '2.3.0'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: JACKSON_VERSION
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: JACKSON_VERSION
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: JACKSON_VERSION
compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.6'
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '4.0.0'
compile group: 'com.google.guava', name: 'guava', version: '26.0-jre'
compile group: 'commons-io', name: 'commons-io', version: '2.6'
compile group: 'javax.validation', name: 'validation-api', version: '2.0.1.Final'
compile group: 'org.hibernate', name: 'hibernate-validator', version: '6.0.13.Final'
// testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: JUNIT_VERSION
// testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: JUNIT_VERSION
testCompile group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: JUNIT_VERSION
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.22.0'
testCompile group: 'org.springframework', name: 'spring-test', version: SPRING_VERSION
testCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.3'
testCompile group: 'com.jayway.jsonpath', name: 'json-path-assert', version: '2.4.0'
testCompile group: 'com.h2database', name: 'h2', version: '1.4.197'
}
External Libraries 存储 log4j 版本 2.10.0,但需要放 2.8 左右。我无法弄清楚要从哪个依赖项中删除 log4j 以显式设置依赖项。如果有解决方案,请告诉我该怎么做。
一般来说,他们会
spring-boot-starter-data-jpa
分别找出并添加必要的依赖项。错误的那个lombok
在那里。