Spring Boot 和 spring security :创建名为“securityFilterChain”的Bean时出错,运行程序时

v2g6jxz6  于 2022-12-04  发布在  Spring
关注(0)|答案(1)|浏览(149)

嘿,伙计们,我开始实现JWT的webtockens,这样我就可以验证用户了。我遵循了Dan Vega的教程。我不明白这里出了什么问题。
错误:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-12-02 12:36:38.156 ERROR 24500 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Unsatisfied dependency expressed through method 'setFilterChains' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityFilterChain' defined in class path resource [com/Code/Pakket/management/config/SecurityConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.SecurityFilterChain]: Factory method 'securityFilterChain' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/security/oauth2/server/resource/web/BearerTokenResolver
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:767) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:719) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:119) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1431) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:619) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:955) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.23.jar:5.3.23]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.23.jar:5.3.23]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:147) ~[spring-boot-2.7.4.jar:2.7.4]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:734) ~[spring-boot-2.7.4.jar:2.7.4]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:408) ~[spring-boot-2.7.4.jar:2.7.4]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) ~[spring-boot-2.7.4.jar:2.7.4]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1306) ~[spring-boot-2.7.4.jar:2.7.4]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1295) ~[spring-boot-2.7.4.jar:2.7.4]
    at com.Code.Pakket.management.PakketManagementApplication.main(PakketManagementApplication.java:13) ~[classes/:na]
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'securityFilterChain' defined in class path resource [com/Code/Pakket/management/config/SecurityConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.SecurityFilterChain]: Factory method 'securityFilterChain' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/security/oauth2/server/resource/web/BearerTokenResolver
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:276) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.addCandidateEntry(DefaultListableBeanFactory.java:1609) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1573) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveMultipleBeans(DefaultListableBeanFactory.java:1462) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1349) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.resolveMethodArguments(AutowiredAnnotationBeanPostProcessor.java:759) ~[spring-beans-5.3.23.jar:5.3.23]
    ... 20 common frames omitted
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.SecurityFilterChain]: Factory method 'securityFilterChain' threw exception; nested exception is java.lang.NoClassDefFoundError: org/springframework/security/oauth2/server/resource/web/BearerTokenResolver
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.23.jar:5.3.23]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.23.jar:5.3.23]
    ... 36 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/springframework/security/oauth2/server/resource/web/BearerTokenResolver
    at com.Code.Pakket.management.config.SecurityConfig.securityFilterChain(SecurityConfig.java:50) ~[classes/:na]
    at com.Code.Pakket.management.config.SecurityConfig$$EnhancerBySpringCGLIB$$afbac66.CGLIB$securityFilterChain$0(<generated>) ~[classes/:na]
    at com.Code.Pakket.management.config.SecurityConfig$$EnhancerBySpringCGLIB$$afbac66$$FastClassBySpringCGLIB$$6816d5e3.invoke(<generated>) ~[classes/:na]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:244) ~[spring-core-5.3.23.jar:5.3.23]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:331) ~[spring-context-5.3.23.jar:5.3.23]
    at com.Code.Pakket.management.config.SecurityConfig$$EnhancerBySpringCGLIB$$afbac66.securityFilterChain(<generated>) ~[classes/:na]
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:578) ~[na:na]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.23.jar:5.3.23]
    ... 37 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.springframework.security.oauth2.server.resource.web.BearerTokenResolver
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ~[na:na]
    ... 46 common frames omitted

Process finished with exit code 1

securityConfig文件:

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.annotation.web.configurers.oauth2.server.resource.OAuth2ResourceServerConfigurer;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.oauth2.jwt.JwtDecoder;
import org.springframework.security.oauth2.jwt.NimbusJwtDecoder;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
import org.springframework.security.web.savedrequest.HttpSessionRequestCache;
import org.springframework.security.web.savedrequest.RequestCache;
import org.springframework.security.web.savedrequest.SimpleSavedRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import static org.springframework.security.config.Customizer.*;

@Configuration
@EnableWebSecurity
public class SecurityConfig {

    private final RsaKeyProperties rsaKeys;

    public SecurityConfig(RsaKeyProperties rsaKeys) {
        this.rsaKeys = rsaKeys;
    }

    @Bean
    public InMemoryUserDetailsManager bedrijf() {
        return new InMemoryUserDetailsManager(
                User.withUsername("cezar")
                        .password("{noop}password")
                        .authorities("read")
                        .build()
        );
    }

    @Bean
    public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
        return http
                .csrf(csrf -> csrf.disable())
                .authorizeRequests(auth -> auth
                        .anyRequest().authenticated()
                )
                .oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt)
                .sessionManagement(session -> session.sessionCreationPolicy(SessionCreationPolicy.STATELESS))
                .httpBasic(withDefaults())
                .build();
    }

    @Bean
    JwtDecoder jwtDecoder() {
        return NimbusJwtDecoder.withPublicKey(rsaKeys.publicKey()).build();
    }
}

我做了私钥和公钥。
私钥:

-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC7gFZsX3SqZ5qH
4WTZyN2TIjJDJ6P0JojpUfH94y6yMS4DOEWXvPJ+uKQnWjGz/8q5p+e1KZonWRnS
gyFV6fltskhkNMTUQXecIk7sLKHs9zxTpx3nCcGAsyWy2vXN4u0+hz04p2xQ+By1
vbfDsQz7M7jnv7B6IwTLs6Wg8orZ5iTus5CuuAAh7B4RMvQyMv+FS9arDLjjv0lX
WXsiqinaw/GSpPUXsZTYdxGKCHhYumihm/fdQOdwnhMkUK+EmrAZ9ASOLaMkQ6Qh
QRSemuXgctsr6+WSdhmDrnkU03O6s+3/dJfoUzpF3FgTFTFR05PhOlTssXbuY8cF
m2bwlB5lAgMBAAECggEADf4AdQs/5DeMYKIr/ynuNGdTjjoMZ3vjW7CxzlsrG5Zv
80LlGUhluu8se4NPkjnUdxEAnumr3KPZjswaVhRPziUvzHU4+winqbnQX0TgEJRN
UYYhxSFalLAfGr8cThumeLQUQtYQ+eSKFUXty2dlq0QA2HUwRkJhaTzOxLlU2KMj
StMSA3bYZKqakOSZW4uIF2JG4mM/v2BAyYjYVfule5DMpiIjqeQT/XZVdOYl7lkG
QsOjR5IFj1Y4w6miXQT3NHBSR+NtW8vLecaqRVyblwl4dWMgfmvURkoCcREf81kW
REc69FPwBodbGFfjPNEZuJIvHtNtZLBT6HzR0RgAAQKBgQDrg0HOVDGgtYgLj+12
4y7/tD8LSwyM3Mf4zhQc6Yxin6clypZJPdCXnih2a/1k9YU/19TEa6gK+gtBs3y8
ys/NYddptH9tbwEvfo774a6OzrXkpg2dbwpf5SUH0MHwFAtNBABMh1UNzjAGvCK6
ZT8h4oVqiT4ms5B5l9z0tHNSZQKBgQDLz+RiiPZCEPHucsxZ2KuXQQNkrMz4zS13
G5xfHzlf1tchrrdWEvufEQH10YBRr8FXWd7ksGmNYvkhC6Rz6bScJ6pZ7plGxzSs
vIvq4fjaXj7N0t8XM84ho6bbVFpTHsmgSFt9BlH58q4v2tbHW736j8+Xs3Bwv0WX
gYbo/ercAQKBgD+22Ny7BloWAmIuY+3f9F0VJGEnwpNxP2BeUC6qOGKOEqg0sIfM
A1yhWwz+liT0D0KAX31sKqAdmWIC7uIcdC96Is7kF/1BJK72rDQUkCbuYWMkUVag
LcxXr7b3kSAkLBJ/3JzXl/kOKQwJZdPLhFLkd3ek/X124sUigpJpJzHJAoGBAKPe
af2Dq6Qg5bRXntBaclRxlF3cxg0BQx3yGD8u5r2VCnHtfUD6kE8rqIzRvj9vdZ9b
BeiPor5oJnCYYMhFzs6C4efe/GQ5BLQiAMmAmMpSXmK0umR4ZbMMVrsgTmNobKqv
oseaTk0N/1lAtdGihNQxzrJlNvGgCD8xiJxKlAwBAoGBALchRMiNl1lAKTUeqDuY
wmWDhuqnmEMir9A2Is6+vTL4xxmKzuLmAdOhH8TA9Hw15t9vEUVxLDRTy2nqxGWs
/rGz3hCcU2UpC3wOZ0vZoo4Iwtv4ECQtbksi2esSnhiMAQRKx0RBVYeZ3oRi5Bbd
ewpJ1nnbkKwFcc5lMr5r4BFn
-----END PRIVATE KEY-----

公开密钥:

-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAu4BWbF90qmeah+Fk2cjd
kyIyQyej9CaI6VHx/eMusjEuAzhFl7zyfrikJ1oxs//KuafntSmaJ1kZ0oMhVen5
bbJIZDTE1EF3nCJO7Cyh7Pc8U6cd5wnBgLMlstr1zeLtPoc9OKdsUPgctb23w7EM
+zO457+weiMEy7OloPKK2eYk7rOQrrgAIeweETL0MjL/hUvWqwy4479JV1l7Iqop
2sPxkqT1F7GU2HcRigh4WLpooZv33UDncJ4TJFCvhJqwGfQEji2jJEOkIUEUnprl
4HLbK+vlknYZg655FNNzurPt/3SX6FM6RdxYExUxUdOT4TpU7LF27mPHBZtm8JQe
ZQIDAQAB
-----END PUBLIC KEY-----

我创建了一个RsaKeyProperties文件:

import org.springframework.boot.context.properties.ConfigurationProperties;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;

@ConfigurationProperties(prefix = "rsa")
public record RsaKeyProperties(RSAPublicKey publicKey, RSAPrivateKey privateKey) {
}

我启用了RsaKeyPropertiesFile:

import com.Code.Pakket.management.config.RsaKeyProperties;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

@EnableConfigurationProperties({RsaKeyProperties.class})
@SpringBootApplication
public class PakketManagementApplication {

    public static void main(String[] args) {
        SpringApplication.run(PakketManagementApplication.class, args);
    }

}

我使用属性文件中的公钥和私钥:

#configuration
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/pakketjesdb
#spring.datasource.url=jdbc:mysql://host.docker.internal:3306/pakketjesdb
spring.datasource.username=pakketjesdb
spring.datasource.password=patriot12345

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

rsa.private-key=classpath:certs/private.pem
rsa.public-key=classpath:certs/public.pem

最后是依赖性:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.4</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.Code</groupId>
    <artifactId>Pakket-management</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>Pakket-management</name>
    <description>Full stack application - Springboot &amp; React</description>
    <properties>
        <java.version>19</java.version>
        <sonar.organization>cezarpop12</sonar.organization>
        <sonar.host.url>https://sonarcloud.io</sonar.host.url>
        <junit.jupiter.version>5.9.1</junit.jupiter.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.springframework/spring-websocket -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-websocket</artifactId>
            <version>6.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
            <version>2.7.5</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
            <version>3.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-oauth2-jose</artifactId>
            <version>6.0.0</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>18</source>
                    <target>18</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>   <configuration>
                <argLine>
                    --illegal-access=permit
                </argLine>
                <testFailureIgnore>true</testFailureIgnore>
                <forkCount>2</forkCount>
                <reuseForks>true</reuseForks>
                <argLine>${surefireArgLine}</argLine>
            </configuration>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.8</version>
                <executions>
                    <execution>
                    <id>default-prepare-agent</id>
                    <goals>
                        <goal>prepare-agent</goal>
                    </goals>
                    <configuration>
                        <destFile>
                            ${project.build.directory}/coverage-reports/jacoco.exec
                        </destFile>
                        <propertyName>surefireArgLine</propertyName>
                    </configuration>
                </execution>
                    <execution>
                        <id>default-report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                        <configuration>
                            <dataFile>${project.build.directory}/coverage-reports/jacoco.exec</dataFile>
                            <outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
lrpiutwd

lrpiutwd1#

错误显示
导致的原因:java.lang.类未找到异常:org.springframework.security.oauth2.server.resource.web.BearerTokenResolver
请在项目中添加spring-boot-starter-oauth2-resource-server依赖项。
更多解决方案请访问BearerTokenAccessDeniedHandler Class Definition Not found

相关问题