gpt4 book ai didi

gradle - Spring Boot应用程序的Gradle构建异常

转载 作者:行者123 更新时间:2023-12-03 05:46:40 30 4
gpt4 key购买 nike

我试图在Eclipse中使用Gradle运行Spring Boot应用程序。它给bootRun一个异常(exception)。我尝试了几乎所有与此异常(exception)相关的组合。我试图在 Spring 启动应用程序中排除冲突的tomcat jar。但是它没有用。

异常(exception):

org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is java.lang.NoSuchMethodError: javax.servlet.ServletContext.getClassLoader()Ljava/lang/ClassLoader;
11:41:28.968 [QUIET] [system.out] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137)
11:41:28.968 [QUIET] [system.out] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:536)
11:41:28.969 [QUIET] [system.out] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
11:41:28.969 [QUIET] [system.out] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)
11:41:28.970 [QUIET] [system.out] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371)
11:41:28.970 [QUIET] [system.out] at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
11:41:28.970 [QUIET] [system.out] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186)
11:41:28.970 [QUIET] [system.out] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175)
11:41:28.970 [QUIET] [system.out] at com.att.it.wpwcm.main.Application.main(Application.java:15)
11:41:28.970 [QUIET] [system.out] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
11:41:28.970 [QUIET] [system.out] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
11:41:28.971 [QUIET] [system.out] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
11:41:28.971 [QUIET] [system.out] at java.lang.reflect.Method.invoke(Method.java:498)
11:41:28.971 [QUIET] [system.out] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
11:41:28.971 [QUIET] [system.out] Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getClassLoader()Ljava/lang/ClassLoader;
11:41:28.971 [QUIET] [system.out] at io.undertow.websockets.jsr.Bootstrap.handleDeployment(Bootstrap.java:93)
11:41:28.971 [QUIET] [system.out] at io.undertow.servlet.core.DeploymentManagerImpl.handleExtensions(DeploymentManagerImpl.java:252)
11:41:28.971 [QUIET] [system.out] at io.undertow.servlet.core.DeploymentManagerImpl.deploy(DeploymentManagerImpl.java:152)
11:41:28.972 [QUIET] [system.out] at org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory.createDeploymentManager(UndertowEmbeddedServletContainerFactory.java:394)
11:41:28.972 [QUIET] [system.out] at org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory.getEmbeddedServletContainer(UndertowEmbeddedServletContainerFactory.java:228)
11:41:28.972 [QUIET] [system.out] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:164)
11:41:28.972 [QUIET] [system.out] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:134)
11:41:28.972 [QUIET] [system.out] ... 13 common frames omitted
11:41:28.973 [QUIET] [system.out]

我的build.gradle文件:
    buildscript {
repositories {
maven { url "https://repo.spring.io/libs-release" }
maven { url "https://repo1.maven.org/maven2/" }
mavenLocal()
mavenCentral()
jcenter()
maven { url "http://oss.jfrog.org/artifactory/oss-snapshot-local/" }
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.2.RELEASE")
classpath("org.springframework:spring-web:3.0.4.RELEASE")
classpath("org.springframework:spring-context-support:3.2.0.RELEASE")
classpath("org.springframework:spring-webmvc:4.1.6.RELEASE")
classpath("io.springfox:springfox-swagger2:2.5.0")
}

}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'

jar {
baseName = 'wpwcm-batch-db'
version = '0.1.0'
}

bootRepackage {
mainClass = 'com.att.it.wpwcm.main.Application'
}

repositories {
mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

configurations {
compile.exclude module: "spring-boot-starter-tomcat"
}

dependencies {
compile("org.springframework.boot:spring-boot-starter-batch")
compile("org.hsqldb:hsqldb")
compile 'javax.mail:mail:1.4.1'
compile 'org.springframework:spring-context'
compile group: 'org.springframework', name: 'spring-context-support', version: '3.2.0.RELEASE'
compile group: 'org.springframework', name: 'spring-web', version: '4.3.4.RELEASE'
compile group: 'org.springframework', name: 'spring-webmvc', version: '4.1.6.RELEASE'
compile("org.springframework.boot:spring-boot-starter-web")
compile("org.springframework.boot:spring-boot-starter-undertow:1.2.3.RELEASE")
compile("org.springframework.boot:spring-boot-starter-activemq")
compile group: 'com.google.code.gson', name: 'gson', version: '1.7.2'
compile("io.springfox:springfox-swagger2:2.5.0")
compile("io.springfox:springfox-swagger-ui:2.0.2")
testCompile("junit:junit")
//compile group: 'org.codehaus.jackson', name: 'jackson-mapper-asl', version: '1.9.8'
compile("org.slf4j:jul-to-slf4j")
compile("org.springframework.boot:spring-boot-starter-logging")
//compile("org.springframework.boot:spring-boot-starter-actuator")
compile fileTree(dir: 'libs', include: ['*.jar'])
compile("org.springframework.boot:spring-boot-devtools")

}

最佳答案

尝试以下命令:

./gradlew clean

而这个命令:
./gradlew build

它应该修复bootRun异常。

关于gradle - Spring Boot应用程序的Gradle构建异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49802159/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com