一尘不染

Spring Boot异常:java.lang.NoSuchMethodError:StandardJarScanner.setJarScanFilter(Lorg / apache / tomcat / JarScanFilter;)V

tomcat

我能够为Spring Boot应用程序成功完成gradle构建(spring-boot-gradle-
plugin:1.2.6.RELEASE),但是在尝试运行时出现以下异常。我相信对此也提出了类似的问题,但我应该能够根据《入门指南》(http://spring.io/guides/gs/spring-
boot/)使用1.2.6.RELEASE运行Spring
Boot。

关于如何解决此错误的任何想法?

build.gradle的在下面列出,后面是异常

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'spring-boot'

mainClassName = "com.avada.base.Application"

sourceCompatibility = 1.8
targetCompatibility = 1.8

sourceSets {
    main {
        java {
            srcDir 'src'
        }
    }
    test {
        java {
            srcDir 'test'
        }
    }
}

jar {
    baseName = 'IR360'
    version =  '6.0.0'
}

repositories {
    mavenCentral()
}

configurations {
    all*.exclude module : 'spring-boot-starter-logging'
}

dependencies {
    compile ('org.springframework.boot:spring-boot-starter-web')
    compile("org.springframework.boot:spring-boot-starter-actuator")
    testCompile("junit:junit")

    compile fileTree(dir: 'aux-lib', include: '*.jar')
    compile fileTree(dir: 'common/lib', include: '*.jar')
    compile fileTree(dir: 'WebContent/WEB-INF/lib', include: '*.jar')
}

task wrapper(type: Wrapper) {
    gradleVersion = '2.7'
}

 .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.2.6.RELEASE)

Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is java.lang.NoSuchMethodError: org.apache.tomcat.util.scan.StandardJarScanner.setJarScanFilter(Lorg/apache/tomcat/JarScanFilter;)V
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:133)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:474)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:687)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:321)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:967)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:956)
    at com.avada.base.Application.main(Application.java:15)
Caused by: java.lang.NoSuchMethodError: org.apache.tomcat.util.scan.StandardJarScanner.setJarScanFilter(Lorg/apache/tomcat/JarScanFilter;)V
    at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner$Tomcat8TldSkipSetter.setSkipPattern(SkipPatternJarScanner.java:106)
    at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.setPatternToTomcat8SkipFilter(SkipPatternJarScanner.java:61)
    at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.<init>(SkipPatternJarScanner.java:56)
    at org.springframework.boot.context.embedded.tomcat.SkipPatternJarScanner.apply(SkipPatternJarScanner.java:87)
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.prepareContext(TomcatEmbeddedServletContainerFactory.java:168)
    at org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory.getEmbeddedServletContainer(TomcatEmbeddedServletContainerFactory.java:154)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:157)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:130)
    ... 7 more
:run FAILED

阅读 499

收藏
2020-06-16

共1个答案

一尘不染

您在类路径上具有旧的和不兼容的Tomcat版本。查看您的build.gradle,它一定来自您的fileTree依赖项之一。您应该更新它们的配置,以确保classpath上仅有的Tomcat依赖项是由引入的spring- boot-starter-web。如果您不确定要从何处加载旧的Tomcat类,请运行-verbose:class并告诉您。

2020-06-16