【发布时间】:2016-01-14 11:14:15
【问题描述】:
我能够为 Spring Boot 应用程序 (spring-boot-gradle-plugin:1.2.6.RELEASE) 成功进行 gradle 构建,但是当我尝试运行时出现以下异常。我相信有人对此提出了类似的问题,但我应该能够按照入门指南使用 1.2.6.RELEASE 运行 Spring Boot - http://spring.io/guides/gs/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
【问题讨论】:
-
你试过看this的答案吗?
-
@wero 我会冒险走下正在运行的与正在编译的不同的路径,但我使用
gradle build然后java -jar运行它,所以我认为编译和运行时课程是一样的...不过我会深入研究并确认 -
@CoryKlein 是的 - 我想让它在 Spring Boot 1.2.6 中工作,而不是使用旧版本
-
不幸的是,我不相信您的问题包含诊断问题所需的一切。尝试包含一个重现问题的最小项目。
标签: java spring tomcat gradle spring-boot