Spring Boot异常:java.lang.NoSuchMethodError:StandardJarScanner.setJarScanFilter(Lorg/apache/tomcat/JarScanFilter;)V [英] Spring Boot exception: java.lang.NoSuchMethodError: StandardJarScanner.setJarScanFilter(Lorg/apache/tomcat/JarScanFilter;)V
问题描述
我能够为Spring Boot应用程序成功完成gradle构建(spring-boot-gradle-plugin:1.2.6.RELEASE),但是在尝试运行时出现以下异常.我相信对此也提出了类似的问题,但我应该能够按照《入门指南》-
I'm able to do a gradle build successfully for a Spring Boot app (spring-boot-gradle-plugin:1.2.6.RELEASE) but I'm getting the exception below when I attempt to run. I believe a similar question has been asked on this but I should be able to run Spring Boot using 1.2.6.RELEASE per the Getting Started guide - http://spring.io/guides/gs/spring-boot/
关于如何解决此错误的任何想法?
Any ideas on how to get around this error?
下面列出了我的build.gradle
,后面是异常
My build.gradle
is listed below followed by the exception
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
推荐答案
您在类路径上具有旧的和不兼容的Tomcat版本.查看您的build.gradle
,它必须来自您的fileTree
依赖项之一.您应该更新它们的配置,以确保类路径上唯一的Tomcat依赖项是由spring-boot-starter-web
引入的依赖项.如果不确定从哪里下载旧的Tomcat类,请使用-verbose:class
运行该应用程序.
You have an old and incompatible version of Tomcat on the classpath. Looking at your build.gradle
, it must be coming from one of your fileTree
dependencies. You should update their configuration to ensure that the only Tomcat dependencies on the classpath are those that are pulled in by spring-boot-starter-web
. If you're not sure where the old Tomcat classes are being loaded from, running the app with -verbose:class
will tell you.
这篇关于Spring Boot异常:java.lang.NoSuchMethodError:StandardJarScanner.setJarScanFilter(Lorg/apache/tomcat/JarScanFilter;)V的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!