Spring @ControllerAdvice - NoClassDefFoundError: исключение javax / servlet / ServletException - PullRequest
0 голосов
/ 26 апреля 2020

У меня есть мой ExceptionHandler в весеннем проекте. Я хочу использовать @ControllerAdvice в моем проекте, но у меня есть некоторые проблемы с этим. Когда я строю проект, у меня возникают ошибки, но если я комментирую @ControllerAdvice, мой проект строится нормально. Для сборки я использую gradle. Ниже я добавляю код ошибок, MyExceptionHandler и build.gradle.

java.lang.NoClassDefFoundError: javax/servlet/ServletException
    at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[na:na]
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017) ~[na:na]
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151) ~[na:na]
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:821) ~[na:na]
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:719) ~[na:na]
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:642) ~[na:na]
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:600) ~[na:na]
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
    at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[na:na]
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017) ~[na:na]
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151) ~[na:na]
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:821) ~[na:na]
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:719) ~[na:na]
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:642) ~[na:na]
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:600) ~[na:na]
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
    at java.base/java.lang.ClassLoader.defineClass1(Native Method) ~[na:na]
    at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017) ~[na:na]
    at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:151) ~[na:na]
    at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:821) ~[na:na]
    at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:719) ~[na:na]
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:642) ~[na:na]
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:600) ~[na:na]
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
    at java.base/java.lang.Class.getDeclaredConstructors0(Native Method) ~[na:na]
    at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3215) ~[na:na]
    at java.base/java.lang.Class.getDeclaredConstructors(Class.java:2435) ~[na:na]
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindConstructorProvider.findConstructorBindingAnnotatedConstructor(ConfigurationPropertiesBindConstructorProvider.java:62) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindConstructorProvider.getBindConstructor(ConfigurationPropertiesBindConstructorProvider.java:48) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
    at org.springframework.boot.context.properties.ConfigurationPropertiesBean$BindMethod.forType(ConfigurationPropertiesBean.java:311) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
    at org.springframework.boot.context.properties.ConfigurationPropertiesBeanDefinitionValidator.validate(ConfigurationPropertiesBeanDefinitionValidator.java:63) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
    at org.springframework.boot.context.properties.ConfigurationPropertiesBeanDefinitionValidator.postProcessBeanFactory(ConfigurationPropertiesBeanDefinitionValidator.java:45) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:286) ~[spring-context-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:174) ~[spring-context-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:706) ~[spring-context-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[spring-context-5.2.5.RELEASE.jar:5.2.5.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) ~[spring-boot-2.2.6.RELEASE.jar:2.2.6.RELEASE]
    at com.andreirozov.cyclingserver.CyclingserverApplication.main(CyclingserverApplication.java:10) ~[main/:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
    at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) ~[spring-boot-devtools-2.2.6.RELEASE.jar:2.2.6.RELEASE]
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletException
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:602) ~[na:na]
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) ~[na:na]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522) ~[na:na]
    ... 50 common frames omitted

Мой обработчик исключений:

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;

@ControllerAdvice
public class MyExceptionHandler extends ResponseEntityExceptionHandler {

    @ExceptionHandler(EmptyListException.class)
    protected ResponseEntity<MyException> handleEmptyListException() {
        return new ResponseEntity<>(new MyException("Unexpected empty list"), HttpStatus.NOT_FOUND);
    }

    @ExceptionHandler(ParseException.class)
    protected ResponseEntity<MyException> handleParseException() {
        return new ResponseEntity<>(new MyException("Jsoup parse error"), HttpStatus.NOT_FOUND);
    }

    protected static class MyException {
        private String message;

        public MyException(String m) {
            message = m;
        }

        public String getMessage() {
            return message;
        }

        public void setMessage(String message) {
            this.message = message;
        }
    }
}

Мой build.gradle:

plugins {
    id 'org.springframework.boot' version '2.2.6.RELEASE'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
    id 'java'
    id 'war'
}

group = 'com.andreirozov'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '14'

configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    compile 'org.jsoup:jsoup:1.13.1'
    compile 'org.springframework.boot:spring-boot-starter-hateoas'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
}

test {
    useJUnitPlatform()
}

Зависимости дерево:

compileClasspath - Compile classpath for source set 'main'.
+--- org.jsoup:jsoup:1.13.1
+--- org.springframework.boot:spring-boot-starter-hateoas -> 2.2.6.RELEASE
|    +--- org.springframework.boot:spring-boot-starter-web:2.2.6.RELEASE
|    |    +--- org.springframework.boot:spring-boot-starter:2.2.6.RELEASE
|    |    |    +--- org.springframework.boot:spring-boot:2.2.6.RELEASE
|    |    |    |    +--- org.springframework:spring-core:5.2.5.RELEASE
|    |    |    |    |    \--- org.springframework:spring-jcl:5.2.5.RELEASE
|    |    |    |    \--- org.springframework:spring-context:5.2.5.RELEASE
|    |    |    |         +--- org.springframework:spring-aop:5.2.5.RELEASE
|    |    |    |         |    +--- org.springframework:spring-beans:5.2.5.RELEASE
|    |    |    |         |    |    \--- org.springframework:spring-core:5.2.5.RELEASE (*)
|    |    |    |         |    \--- org.springframework:spring-core:5.2.5.RELEASE (*)
|    |    |    |         +--- org.springframework:spring-beans:5.2.5.RELEASE (*)
|    |    |    |         +--- org.springframework:spring-core:5.2.5.RELEASE (*)
|    |    |    |         \--- org.springframework:spring-expression:5.2.5.RELEASE
|    |    |    |              \--- org.springframework:spring-core:5.2.5.RELEASE (*)
|    |    |    +--- org.springframework.boot:spring-boot-autoconfigure:2.2.6.RELEASE
|    |    |    |    \--- org.springframework.boot:spring-boot:2.2.6.RELEASE (*)
|    |    |    +--- org.springframework.boot:spring-boot-starter-logging:2.2.6.RELEASE
|    |    |    |    +--- ch.qos.logback:logback-classic:1.2.3
|    |    |    |    |    +--- ch.qos.logback:logback-core:1.2.3
|    |    |    |    |    \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
|    |    |    |    +--- org.apache.logging.log4j:log4j-to-slf4j:2.12.1
|    |    |    |    |    +--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
|    |    |    |    |    \--- org.apache.logging.log4j:log4j-api:2.12.1
|    |    |    |    \--- org.slf4j:jul-to-slf4j:1.7.30
|    |    |    |         \--- org.slf4j:slf4j-api:1.7.30
|    |    |    +--- jakarta.annotation:jakarta.annotation-api:1.3.5
|    |    |    \--- org.springframework:spring-core:5.2.5.RELEASE (*)
|    |    +--- org.springframework.boot:spring-boot-starter-json:2.2.6.RELEASE
|    |    |    +--- org.springframework.boot:spring-boot-starter:2.2.6.RELEASE (*)
|    |    |    +--- org.springframework:spring-web:5.2.5.RELEASE
|    |    |    |    +--- org.springframework:spring-beans:5.2.5.RELEASE (*)
|    |    |    |    \--- org.springframework:spring-core:5.2.5.RELEASE (*)
|    |    |    +--- com.fasterxml.jackson.core:jackson-databind:2.10.3
|    |    |    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.10.3
|    |    |    |    \--- com.fasterxml.jackson.core:jackson-core:2.10.3
|    |    |    +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.3
|    |    |    |    +--- com.fasterxml.jackson.core:jackson-core:2.10.3
|    |    |    |    \--- com.fasterxml.jackson.core:jackson-databind:2.10.3 (*)
|    |    |    +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.3
|    |    |    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.10.3
|    |    |    |    +--- com.fasterxml.jackson.core:jackson-core:2.10.3
|    |    |    |    \--- com.fasterxml.jackson.core:jackson-databind:2.10.3 (*)
|    |    |    \--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.10.3
|    |    |         +--- com.fasterxml.jackson.core:jackson-core:2.10.3
|    |    |         \--- com.fasterxml.jackson.core:jackson-databind:2.10.3 (*)
|    |    +--- org.springframework.boot:spring-boot-starter-tomcat:2.2.6.RELEASE
|    |    |    +--- jakarta.annotation:jakarta.annotation-api:1.3.5
|    |    |    +--- org.apache.tomcat.embed:tomcat-embed-core:9.0.33
|    |    |    +--- org.apache.tomcat.embed:tomcat-embed-el:9.0.33
|    |    |    \--- org.apache.tomcat.embed:tomcat-embed-websocket:9.0.33
|    |    |         \--- org.apache.tomcat.embed:tomcat-embed-core:9.0.33
|    |    +--- org.springframework.boot:spring-boot-starter-validation:2.2.6.RELEASE
|    |    |    +--- org.springframework.boot:spring-boot-starter:2.2.6.RELEASE (*)
|    |    |    +--- jakarta.validation:jakarta.validation-api:2.0.2
|    |    |    \--- org.hibernate.validator:hibernate-validator:6.0.18.Final
|    |    |         +--- org.jboss.logging:jboss-logging:3.3.2.Final -> 3.4.1.Final
|    |    |         \--- com.fasterxml:classmate:1.3.4 -> 1.5.1
|    |    +--- org.springframework:spring-web:5.2.5.RELEASE (*)
|    |    \--- org.springframework:spring-webmvc:5.2.5.RELEASE
|    |         +--- org.springframework:spring-aop:5.2.5.RELEASE (*)
|    |         +--- org.springframework:spring-beans:5.2.5.RELEASE (*)
|    |         +--- org.springframework:spring-context:5.2.5.RELEASE (*)
|    |         +--- org.springframework:spring-core:5.2.5.RELEASE (*)
|    |         +--- org.springframework:spring-expression:5.2.5.RELEASE (*)
|    |         \--- org.springframework:spring-web:5.2.5.RELEASE (*)
|    \--- org.springframework.hateoas:spring-hateoas:1.0.4.RELEASE
|         +--- org.springframework:spring-aop:5.2.5.RELEASE (*)
|         +--- org.springframework:spring-beans:5.2.5.RELEASE (*)
|         +--- org.springframework:spring-context:5.2.5.RELEASE (*)
|         +--- org.springframework:spring-core:5.2.5.RELEASE (*)
|         +--- org.springframework:spring-web:5.2.5.RELEASE (*)
|         +--- org.springframework.plugin:spring-plugin-core:2.0.0.RELEASE
|         |    +--- org.springframework:spring-beans:5.2.0.RELEASE -> 5.2.5.RELEASE (*)
|         |    +--- org.springframework:spring-context:5.2.0.RELEASE -> 5.2.5.RELEASE (*)
|         |    +--- org.springframework:spring-aop:5.2.0.RELEASE -> 5.2.5.RELEASE (*)
|         |    \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
|         +--- com.jayway.jsonpath:json-path:2.4.0
|         |    +--- net.minidev:json-smart:2.3
|         |    |    \--- net.minidev:accessors-smart:1.2
|         |    |         \--- org.ow2.asm:asm:5.0.4
|         |    \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
|         \--- org.slf4j:slf4j-api:1.7.30
+--- org.springframework.boot:spring-boot-starter-web -> 2.2.6.RELEASE (*)
\--- javax.servlet:javax.servlet-api:3.1.0

runtimeClasspath - Runtime classpath of source set 'main'.
+--- org.jsoup:jsoup:1.13.1
+--- org.springframework.boot:spring-boot-starter-hateoas -> 2.2.6.RELEASE
|    +--- org.springframework.boot:spring-boot-starter-web:2.2.6.RELEASE
|    |    +--- org.springframework.boot:spring-boot-starter:2.2.6.RELEASE
|    |    |    +--- org.springframework.boot:spring-boot:2.2.6.RELEASE
|    |    |    |    +--- org.springframework:spring-core:5.2.5.RELEASE
|    |    |    |    |    \--- org.springframework:spring-jcl:5.2.5.RELEASE
|    |    |    |    \--- org.springframework:spring-context:5.2.5.RELEASE
|    |    |    |         +--- org.springframework:spring-aop:5.2.5.RELEASE
|    |    |    |         |    +--- org.springframework:spring-beans:5.2.5.RELEASE
|    |    |    |         |    |    \--- org.springframework:spring-core:5.2.5.RELEASE (*)
|    |    |    |         |    \--- org.springframework:spring-core:5.2.5.RELEASE (*)
|    |    |    |         +--- org.springframework:spring-beans:5.2.5.RELEASE (*)
|    |    |    |         +--- org.springframework:spring-core:5.2.5.RELEASE (*)
|    |    |    |         \--- org.springframework:spring-expression:5.2.5.RELEASE
|    |    |    |              \--- org.springframework:spring-core:5.2.5.RELEASE (*)
|    |    |    +--- org.springframework.boot:spring-boot-autoconfigure:2.2.6.RELEASE
|    |    |    |    \--- org.springframework.boot:spring-boot:2.2.6.RELEASE (*)
|    |    |    +--- org.springframework.boot:spring-boot-starter-logging:2.2.6.RELEASE
|    |    |    |    +--- ch.qos.logback:logback-classic:1.2.3
|    |    |    |    |    +--- ch.qos.logback:logback-core:1.2.3
|    |    |    |    |    \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
|    |    |    |    +--- org.apache.logging.log4j:log4j-to-slf4j:2.12.1
|    |    |    |    |    +--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
|    |    |    |    |    \--- org.apache.logging.log4j:log4j-api:2.12.1
|    |    |    |    \--- org.slf4j:jul-to-slf4j:1.7.30
|    |    |    |         \--- org.slf4j:slf4j-api:1.7.30
|    |    |    +--- jakarta.annotation:jakarta.annotation-api:1.3.5
|    |    |    +--- org.springframework:spring-core:5.2.5.RELEASE (*)
|    |    |    \--- org.yaml:snakeyaml:1.25
|    |    +--- org.springframework.boot:spring-boot-starter-json:2.2.6.RELEASE
|    |    |    +--- org.springframework.boot:spring-boot-starter:2.2.6.RELEASE (*)
|    |    |    +--- org.springframework:spring-web:5.2.5.RELEASE
|    |    |    |    +--- org.springframework:spring-beans:5.2.5.RELEASE (*)
|    |    |    |    \--- org.springframework:spring-core:5.2.5.RELEASE (*)
|    |    |    +--- com.fasterxml.jackson.core:jackson-databind:2.10.3
|    |    |    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.10.3
|    |    |    |    \--- com.fasterxml.jackson.core:jackson-core:2.10.3
|    |    |    +--- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.3
|    |    |    |    +--- com.fasterxml.jackson.core:jackson-core:2.10.3
|    |    |    |    \--- com.fasterxml.jackson.core:jackson-databind:2.10.3 (*)
|    |    |    +--- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.3
|    |    |    |    +--- com.fasterxml.jackson.core:jackson-annotations:2.10.3
|    |    |    |    +--- com.fasterxml.jackson.core:jackson-core:2.10.3
|    |    |    |    \--- com.fasterxml.jackson.core:jackson-databind:2.10.3 (*)
|    |    |    \--- com.fasterxml.jackson.module:jackson-module-parameter-names:2.10.3
|    |    |         +--- com.fasterxml.jackson.core:jackson-core:2.10.3
|    |    |         \--- com.fasterxml.jackson.core:jackson-databind:2.10.3 (*)
|    |    +--- org.springframework.boot:spring-boot-starter-tomcat:2.2.6.RELEASE
|    |    |    +--- jakarta.annotation:jakarta.annotation-api:1.3.5
|    |    |    +--- org.apache.tomcat.embed:tomcat-embed-core:9.0.33
|    |    |    +--- org.apache.tomcat.embed:tomcat-embed-el:9.0.33
|    |    |    \--- org.apache.tomcat.embed:tomcat-embed-websocket:9.0.33
|    |    |         \--- org.apache.tomcat.embed:tomcat-embed-core:9.0.33
|    |    +--- org.springframework.boot:spring-boot-starter-validation:2.2.6.RELEASE
|    |    |    +--- org.springframework.boot:spring-boot-starter:2.2.6.RELEASE (*)
|    |    |    +--- jakarta.validation:jakarta.validation-api:2.0.2
|    |    |    \--- org.hibernate.validator:hibernate-validator:6.0.18.Final
|    |    |         +--- org.jboss.logging:jboss-logging:3.3.2.Final -> 3.4.1.Final
|    |    |         \--- com.fasterxml:classmate:1.3.4 -> 1.5.1
|    |    +--- org.springframework:spring-web:5.2.5.RELEASE (*)
|    |    \--- org.springframework:spring-webmvc:5.2.5.RELEASE
|    |         +--- org.springframework:spring-aop:5.2.5.RELEASE (*)
|    |         +--- org.springframework:spring-beans:5.2.5.RELEASE (*)
|    |         +--- org.springframework:spring-context:5.2.5.RELEASE (*)
|    |         +--- org.springframework:spring-core:5.2.5.RELEASE (*)
|    |         +--- org.springframework:spring-expression:5.2.5.RELEASE (*)
|    |         \--- org.springframework:spring-web:5.2.5.RELEASE (*)
|    \--- org.springframework.hateoas:spring-hateoas:1.0.4.RELEASE
|         +--- org.springframework:spring-aop:5.2.5.RELEASE (*)
|         +--- org.springframework:spring-beans:5.2.5.RELEASE (*)
|         +--- org.springframework:spring-context:5.2.5.RELEASE (*)
|         +--- org.springframework:spring-core:5.2.5.RELEASE (*)
|         +--- org.springframework:spring-web:5.2.5.RELEASE (*)
|         +--- org.springframework.plugin:spring-plugin-core:2.0.0.RELEASE
|         |    +--- org.springframework:spring-beans:5.2.0.RELEASE -> 5.2.5.RELEASE (*)
|         |    +--- org.springframework:spring-context:5.2.0.RELEASE -> 5.2.5.RELEASE (*)
|         |    +--- org.springframework:spring-aop:5.2.0.RELEASE -> 5.2.5.RELEASE (*)
|         |    \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
|         +--- com.jayway.jsonpath:json-path:2.4.0
|         |    +--- net.minidev:json-smart:2.3
|         |    |    \--- net.minidev:accessors-smart:1.2
|         |    |         \--- org.ow2.asm:asm:5.0.4
|         |    \--- org.slf4j:slf4j-api:1.7.25 -> 1.7.30
|         \--- org.slf4j:slf4j-api:1.7.30
+--- org.springframework.boot:spring-boot-devtools -> 2.2.6.RELEASE
|    +--- org.springframework.boot:spring-boot:2.2.6.RELEASE (*)
|    \--- org.springframework.boot:spring-boot-autoconfigure:2.2.6.RELEASE (*)
+--- org.springframework.boot:spring-boot-starter-web -> 2.2.6.RELEASE (*)
+--- javax.servlet:javax.servlet-api:3.1.0
\--- org.springframework.boot:spring-boot-starter-tomcat -> 2.2.6.RELEASE (*)

providedRuntime - Additional runtime classpath for libraries that should not be part of the WAR archive.
+--- javax.servlet:javax.servlet-api:3.1.0
\--- org.springframework.boot:spring-boot-starter-tomcat -> 2.2.6.RELEASE
     +--- jakarta.annotation:jakarta.annotation-api:1.3.5
     +--- org.apache.tomcat.embed:tomcat-embed-core:9.0.33
     +--- org.apache.tomcat.embed:tomcat-embed-el:9.0.33
     \--- org.apache.tomcat.embed:tomcat-embed-websocket:9.0.33
          \--- org.apache.tomcat.embed:tomcat-embed-core:9.0.33

1 Ответ

0 голосов
/ 26 апреля 2020

Не требуется для отдельного применения в банке: providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'. Starter-web включает в себя один

Когда вы объявили эту зависимость, вы сказали, что создаете, чтобы исключить tomcat для автономного запуска. Это означает - нет библиотеки сервлетов внутри


Если вы развернете это приложение где-нибудь, просто исключите tomcat из starter-web, например:

compile('org.springframework.boot:spring-boot-starter-web'){
    exclude module: "spring-boot-starter-tomcat"
}
...