gpt4 book ai didi

java - JDK 11 Spring Boot 2 .TypeNotPresentException : Type javax. servlet.Filter 不存在

转载 作者:行者123 更新时间:2023-12-02 05:59:33 26 4
gpt4 key购买 nike

我有以下 pom.xml,其中包含手动 jax deps jaxb-apijaxb-impljaxb-core 由于其从 JDK 11 中删除:

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.0.M2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<properties>
<java.version>11</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-cloud.version>Greenwich.RELEASE</spring-cloud.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.3.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>

<!--TEST-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>

<!--Three below dependencies due to JDK 11 removed jaxb-->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0</version>
</dependency>

<!--For Eureka Client-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>

<!-- Spring Cloud Config Client -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>

</dependencies>
<dependencyManagement>
<dependencies>
<!--To provide version for Eureka Client -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

<repositories>

<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
</pluginRepository>
</pluginRepositories>

mvn clean:install之后,但是当尝试运行应用程序时,我不断收到有关过滤器的错误。

22:45:16.622 [main] DEBUG org.springframework.beans.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'org.springframework.cloud.autoconfigure.RefreshAutoConfiguration$RefreshScopeBeanDefinitionEnhancer' Exception in thread "main" java.lang.TypeNotPresentException: Type javax.servlet.Filter not present at java.base/sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:117) at java.base/sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125) at java.base/sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49) at java.base/sun.reflect.generics.visitor.Reifier.reifyTypeArguments(Reifier.java:68) at java.base/sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:138) at java.base/sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49) at java.base/sun.reflect.generics.repository.ClassRepository.computeSuperInterfaces(ClassRepository.java:117) at java.base/sun.reflect.generics.repository.ClassRepository.getSuperInterfaces(ClassRepository.java:95) at java.base/java.lang.Class.getGenericInterfaces(Class.java:1138) at org.springframework.core.ResolvableType.getInterfaces(ResolvableType.java:491) at org.springframework.core.ResolvableType.as(ResolvableType.java:449) at org.springframework.core.ResolvableType.as(ResolvableType.java:450) at org.springframework.core.ResolvableType.forMethodParameter(ResolvableType.java:1305) at org.springframework.core.ResolvableType.forMethodParameter(ResolvableType.java:1272) at org.springframework.core.ResolvableType.forMethodParameter(ResolvableType.java:1262) at org.springframework.core.BridgeMethodResolver.isResolvedTypeMatch(BridgeMethodResolver.java:157) at org.springframework.core.BridgeMethodResolver.isBridgeMethodFor(BridgeMethodResolver.java:141) at org.springframework.core.BridgeMethodResolver.searchCandidates(BridgeMethodResolver.java:120) at org.springframework.core.BridgeMethodResolver.findBridgedMethod(BridgeMethodResolver.java:82) at org.springframework.core.annotation.AnnotationsScanner.processMethodAnnotations(AnnotationsScanner.java:386) at org.springframework.core.annotation.AnnotationsScanner.processMethodHierarchy(AnnotationsScanner.java:266) at org.springframework.core.annotation.AnnotationsScanner.processMethod(AnnotationsScanner.java:236) at org.springframework.core.annotation.AnnotationsScanner.process(AnnotationsScanner.java:109) at org.springframework.core.annotation.AnnotationsScanner.scan(AnnotationsScanner.java:96) at org.springframework.core.annotation.AnnotationsScanner.scan(AnnotationsScanner.java:77) at org.springframework.core.annotation.TypeMappedAnnotations.scan(TypeMappedAnnotations.java:241) at org.springframework.core.annotation.TypeMappedAnnotations.isPresent(TypeMappedAnnotations.java:97) at org.springframework.core.annotation.AnnotatedElementUtils.hasAnnotation(AnnotatedElementUtils.java:531) at org.springframework.context.annotation.BeanAnnotationHelper.isBeanAnnotated(BeanAnnotationHelper.java:41) at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.isMatch(ConfigurationClassEnhancer.java:439) at org.springframework.context.annotation.ConfigurationClassEnhancer$ConditionalCallbackFilter.accept(ConfigurationClassEnhancer.java:192) at org.springframework.cglib.proxy.Enhancer.emitMethods(Enhancer.java:1214) at org.springframework.cglib.proxy.Enhancer.generateClass(Enhancer.java:723) at org.springframework.cglib.transform.TransformingClassGenerator.generateClass(TransformingClassGenerator.java:33) at org.springframework.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:25) at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanFactoryAwareGeneratorStrategy.generate(ConfigurationClassEnhancer.java:252) at org.springframework.cglib.core.AbstractClassGenerator.generate(AbstractClassGenerator.java:358) at org.springframework.cglib.proxy.Enhancer.generate(Enhancer.java:582) at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:110) at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData$3.apply(AbstractClassGenerator.java:108) at org.springframework.cglib.core.internal.LoadingCache$2.call(LoadingCache.java:54) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at org.springframework.cglib.core.internal.LoadingCache.createEntry(LoadingCache.java:61) at org.springframework.cglib.core.internal.LoadingCache.get(LoadingCache.java:34) at org.springframework.cglib.core.AbstractClassGenerator$ClassLoaderData.get(AbstractClassGenerator.java:134) at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:319) at org.springframework.cglib.proxy.Enhancer.createHelper(Enhancer.java:569) at org.springframework.cglib.proxy.Enhancer.createClass(Enhancer.java:416) at org.springframework.context.annotation.ConfigurationClassEnhancer.createClass(ConfigurationClassEnhancer.java:137) at org.springframework.context.annotation.ConfigurationClassEnhancer.enhance(ConfigurationClassEnhancer.java:109) at org.springframework.context.annotation.ConfigurationClassPostProcessor.enhanceConfigurationClasses(ConfigurationClassPostProcessor.java:429) at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanFactory(ConfigurationClassPostProcessor.java:263) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:286) at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:130) at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:705) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:531) at org.springframework.context.annotation.AnnotationConfigApplicationContext.(AnnotationConfigApplicationContext.java:88) at com.example.authservice.AuthServiceApplication.main(AuthServiceApplication.java:13) Caused by: java.lang.ClassNotFoundException: javax.servlet.Filter at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:398) at java.base/sun.reflect.generics.factory.CoreReflectionFactory.makeNamedType(CoreReflectionFactory.java:114)

添加 3 个额外的依赖项后还有什么问题吗?

最佳答案

spring-security-oauth2 项目目前对 Spring MVC 和 Servlet API 具有很强的依赖性。请引用WebFlux oauth2 doc

关于java - JDK 11 Spring Boot 2 .TypeNotPresentException : Type javax. servlet.Filter 不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55986692/

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