Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot SpringSecurity&x2B;SecurityConfig中发生AWS Cognito连接错误_Spring Boot_Spring Security_Build.gradle_Amazon Cognito_Spring Security Oauth2 - Fatal编程技术网

Spring boot SpringSecurity&x2B;SecurityConfig中发生AWS Cognito连接错误

Spring boot SpringSecurity&x2B;SecurityConfig中发生AWS Cognito连接错误,spring-boot,spring-security,build.gradle,amazon-cognito,spring-security-oauth2,Spring Boot,Spring Security,Build.gradle,Amazon Cognito,Spring Security Oauth2,我正在练习与springboot的AWS cognito链接。 但是,securityconfig中出现了一个神秘的错误。 我不知道为什么会出错。 梯度设置错误吗 这是代码 SecurityConfiguration.class @Configuration public class SecurityConfiguration extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecuri

我正在练习与springboot的AWS cognito链接。 但是,securityconfig中出现了一个神秘的错误。 我不知道为什么会出错。 梯度设置错误吗

这是代码

SecurityConfiguration.class

@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.csrf()
            .and()
            .authorizeRequests()
            .mvcMatchers("/").permitAll().anyRequest().authenticated()
            .and()
            .oauth2Login()
            .and()
            .logout()
            .logoutSuccessUrl("/");
    }
}
@Configuration
public class CognitoWebConfiguration implements WebMvcConfigurer {

@Override
public void addViewControllers(ViewControllerRegistry registry) {
    registry.addViewController("/").setViewName("home");
  }
}
和CognitoWebConfiguration.class

@Configuration
public class SecurityConfiguration extends WebSecurityConfigurerAdapter {

@Override
protected void configure(HttpSecurity http) throws Exception {
    http.csrf()
            .and()
            .authorizeRequests()
            .mvcMatchers("/").permitAll().anyRequest().authenticated()
            .and()
            .oauth2Login()
            .and()
            .logout()
            .logoutSuccessUrl("/");
    }
}
@Configuration
public class CognitoWebConfiguration implements WebMvcConfigurer {

@Override
public void addViewControllers(ViewControllerRegistry registry) {
    registry.addViewController("/").setViewName("home");
  }
}
和build.grade文件

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

group = 'jpabook'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'


configurations {
compileOnly {
    extendsFrom annotationProcessor
    }
}


repositories {
mavenCentral()
}

dependencies {

compile group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'

implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'


implementation 'org.springframework.boot:spring-boot-devtools'


implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.5.6'

compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.h2database:h2'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'


implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity5'
compile group: 'org.springframework.security', name: 'spring-security-oauth2-client', version: '5.3.4.RELEASE'
compile group: 'org.springframework.security', name: 'spring-security-oauth2-jose', version: '5.3.4.RELEASE'


testCompile group: 'org.springframework', name: 'spring-test', version: '2.5'
testCompile group: 'org.springframework.security', name: 'spring-security-test', version: '4.0.0.RELEASE'


}
最后,这是一条错误消息。有点长

org.springframework.beans.factory.UnsatifiedDependencyException:创建名为“securityConfiguration”的bean时出错:通过方法“setContentNegotationStrategy”参数0表示的未满足的依赖关系;嵌套异常为org.springframework.beans.factory.UnsatisfiedDependencyException:创建名为“org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration”的bean时出错:未满足的依赖项通过方法“setConfigurers”参数0表示;嵌套异常为org.springframework.beans.factory.unsatifiedDependencyException:创建名为“org.springframework.security.config.annotation.web.configuration.OAuth2ClientConfiguration$OAuth2ClientWebMsecurityConfiguration”的bean时出错:通过方法“setClientRegistrationRepository”参数0表示的未满足的依赖关系;嵌套异常为org.springframework.beans.factory.BeanCreationException:创建名为“clientRegistrationRepository”的bean时出错,该名称在类路径资源[org/springframework/boot/autoconfigure/security/oauth2/client/servlet/OAuth2ClientRegistrationRepositoryConfiguration.class]中定义:通过工厂方法实例化bean失败;嵌套异常为org.springframework.beans.beanstantiationException:未能实例化[org.springframework.security.oauth2.client.registration.InMemoryClientRegistrationRepository]:工厂方法“clientRegistrationRepository”引发异常;嵌套异常为java.lang.NoSuchFieldError:密码 在org.springframework.beans.factory.annotation.AutowiredNotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredNotationBeanPostProcessor.java:678)~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE] 在org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE] 在org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:376)~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1402)~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:591)~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:514)~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:321)~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE] 在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226)~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:319)~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE] 在org.springframework.beans.factory.support.DefaultListableBeanFactory.PreInstanceSingleton(DefaultListableBeanFactory.java:863)~[spring-beans-5.1.17.RELEASE.jar:5.1.17.RELEASE] 在org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)~[spring-context-5.1.17.RELEASE.jar:5.1.17.RELEASE] 在org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)~[spring-context-5.1.17.RELEASE.jar:5.1.17.RELEASE] 在org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)~[spring-boot-2.1.16.RELEASE.jar:2.1.16.RELEASE] 在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744)~[spring-boot-2.1.16.RELEASE.jar:2.1.16.RELEASE] 在org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391)~[spring-boot-2.1.16.RELEASE.jar:2.1.16.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:312)~[spring-boot-2.1.16.RELEASE.jar:2.1.16.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:1215)~[spring-boot-2.1.16.RELEASE.jar:2.1.16.RELEASE] 在org.springframework.boot.SpringApplication.run(SpringApplication.java:1204)~[spring-boot-2.1.16.RELEASE.jar:2.1.16.RELEASE] 在jpabook.jpashop.jpashopplication.main(jpashopplication.java:13)~[main/:na] 在java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(本机方法)~[na:na] 在java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)~[na:na] 在java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)~[na:na] 在java.base/java.lang.reflect.Method.invoke(Method.java:566)~[na:na] 在org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)~[spring-boot-devtools-2.1.16.RELEASE.jar:2.1.16.RELEASE] 原因:org.springframework.beans.factory.unsatifiedDependencyException:创建名为“org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration”的bean时出错:未满足的依赖项通过方法“setConfigurers”表示