创建名称为“ org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration”且具有依赖项的豆时出错

时间:2018-08-30 06:46:54

标签: spring spring-security spring-cloud spring-security-oauth2

org.springframework.beans.factory.BeanCreationException:创建名称为“ org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration”的bean时出错:自动连接依赖项注入失败;嵌套的异常是org.springframework.beans.factory.BeanCreationException:无法自动装配方法:public void org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.setFilterChainProxySecurityConfigurer(org.springframework.security.config.annotation.ObjectPostProcessor, java.util.List)抛出java.lang.Exception;嵌套异常为org.springframework.beans.factory.BeanExpressionException:表达式解析失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名称为“ org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfiguration”的bean时出错:自动连接依赖项注入失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:无法自动连线字段:私有org.springframework.security.oauth2.provider.token.TokenStore org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfiguration。 tokenStore;嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名称为org.springframework.cloud.security.oauth2.resource.ResourceServerTokenServicesConfiguration $ JwtTokenServicesConfiguration的bean时出错:自动连接依赖项注入失败;嵌套的异常是org.springframework.beans.factory.BeanCreationException:无法自动连线字段:私有org.springframework.cloud.security.oauth2.resource.ResourceServerProperties org.springframework.cloud.security.oauth2.resource.ResourceServerTokenServicesConfiguration $ JwtTokenServicesConfiguration.resource;嵌套的异常是org.springframework.beans.factory.NoSuchBeanDefinitionException:没有找到类型为[org.springframework.cloud.security.oauth2.resource.ResourceServerProperties]的合格Bean作为依赖项:至少应有1个可作为该依赖项的自动装配候选者。依赖项注释:{@ org.springframework.beans.factory.annotation.Autowired(required = true)} 在org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)〜[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE]中 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)〜[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)〜[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)〜[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:306)〜[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE] 在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)〜[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)〜[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)〜[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE] 在org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:368)〜[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)〜[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)〜[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)〜[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE] 在org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)〜[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:306)〜[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE] 在org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)〜[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)〜[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE] 在org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)〜[spring-beans-4.2.4.RELEASE.jar!/:4.2.4.RELEASE] 在org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1060)〜[spring-context-4.2.4.RELEASE.jar!/:4.2.4.RELEASE] 在org.springframework.web.filter.DelegatingFilterProxy.initDelegate(DelegatingFilterProxy.java:326)〜[spring-web-4.2.4.RELEASE.jar!/:4.2.4.RELEASE] 在org.springframework.web.filter.DelegatingFilterProxy.initFilterBean(DelegatingFilterProxy.java:235)〜[spring-web-4.2.4.RELEASE.jar!/:4.2.4.RELEASE] 在org.springframework.web.filter.GenericFilterBean.init(GenericFilterBean.java:199)〜[spring-web-4.2.4.RELEASE.jar!/:4.2.4.RELEASE] 在org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)〜[tomcat-embed-core-8.0.30.jar!/:8.0.30] 在org.apache.catalina.core.ApplicationFilterConfig。(ApplicationFilterConfig.java:109)〜[tomcat-embed-core-8.0.30.jar!/:8.0.30] 在org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4659)上[tomcat-embed-core-8.0.30.jar!/:8.0.30] 在org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5281)[tomcat-embed-core-8.0.30.jar!/:8.0.30] 在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)[tomcat-embed-core-8.0.30.jar!/:8.0.30] 在org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1408)[tomcat-embed-core-8.0.30.jar!/:8.0.30] 在org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1398)[tomcat-embed-core-8.0.30.jar!/:8.0.30] 在java.util.concurrent.FutureTask.run(FutureTask.java:266)[na:1.8.0_181] 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)[na:1.8.0_181] 在java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:624)[na:1.8.0_181] 在java.lang.Thread.run(Thread.java:748)[na:1.8.0_181] 引起原因:org.springframework.beans.factory.BeanCreationException:无法自动装配方法:public void org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.setFilterChainProxySecurityConfigurer(org.springframework.security.config.annotation.ObjectPostProcessor, java.util.List)抛出java.lang.Exception;嵌套异常为org.springframework.beans.factory.BeanExpressionException:表达式解析失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:创建名称为“ org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfiguration”的bean时出错:自动连接依赖项注入失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:无法自动连线字段:私有org.springframework.security.oauth2.provider.token.TokenStore org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfiguration。 tokenStore;嵌套的异常是org.springframework.beans.factory.BeanCreationException:创建名称为org.springframework.cloud.security.oauth2.resource.ResourceServerTokenServicesConfiguration $ JwtTokenServicesConfiguration的bean时出错:自动连接依赖项注入失败;嵌套的异常是org.springframework.beans.factory.BeanCreationException:无法自动连线字段:私有org.springframework.cloud.security.oauth2.resource.ResourceServerProperties org.springframework.cloud.security.oauth2.resource.ResourceServerTokenServicesConfiguration $ JwtTokenServicesConfiguration.resource;嵌套的异常是org.springframework.beans.factory.NoSuchBeanDefinitionException:没有找到类型为[org.springframework.cloud.security.oauth2.resource.ResourceServerProperties]的合格Bean作为依赖项:至少应有1个可作为该依赖项的自动装配候选者。依赖注释:{@ org.springframework.beans.factory.annotation.Autowired(required = true)}

这可能是一个依赖性问题,但我无法解决。以下是我的依赖项:

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-parent</artifactId>
            <version>1.3.2.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-parent</artifactId>
            <version>1.0.0.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>${logback.version}</version>
        </dependency>
    </dependencies>
</dependencyManagement>

<dependencies>

    <dependency>
        <groupId>com.zaxxer</groupId>
        <artifactId>HikariCP</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-jersey</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-oauth2</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-jwt</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.integration</groupId>
        <artifactId>spring-integration-core</artifactId>
    </dependency>

    <dependency>
        <groupId>org.mapdb</groupId>
        <artifactId>mapdb</artifactId>
        <version>1.0.6</version>
    </dependency>

    <dependency>
        <groupId>xml-apis</groupId>
        <artifactId>xml-apis</artifactId>
        <version>1.4.01</version>
    </dependency>

    <dependency>
        <groupId>org.scala-lang</groupId>
        <artifactId>scala-library</artifactId>
        <version>2.10.4</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.batch</groupId>
        <artifactId>spring-batch-test</artifactId>
    </dependency>

    <dependency>
        <groupId>org.easymock</groupId>
        <artifactId>easymock</artifactId>
        <version>3.4</version>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>
    <!--<dependency>-->
        <!--<groupId>com.firebase</groupId>-->
        <!--<artifactId>firebase-client-jvm</artifactId>-->
        <!--<version>[2.5.2,)</version>-->
    <!--</dependency>-->
    <dependency>
        <groupId>org.springframework.ldap</groupId>
        <artifactId>spring-ldap-core</artifactId>
        <version>2.0.3.RELEASE</version>
    </dependency>
    <!--<dependency>-->
        <!--<groupId>com.firebase</groupId>-->
        <!--<artifactId>firebase-token-generator</artifactId>-->
        <!--<version>2.0.0</version>-->
    <!--</dependency>-->
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-collections4</artifactId>
        <version>4.1</version>
    </dependency>

    <dependency>
        <groupId>com.opencsv</groupId>
        <artifactId>opencsv</artifactId>
        <version>3.3</version>
    </dependency>

    <dependency>
      <groupId>com.google.apis</groupId>
      <artifactId>google-api-services-gmail</artifactId>
      <version>v1-rev73-1.23.0</version>
    </dependency>
    <dependency>
        <groupId>com.google.api-client</groupId>
        <artifactId>google-api-client</artifactId>
        <version>1.23.0</version>
    </dependency>

    <dependency>
        <groupId>com.google.oauth-client</groupId>
        <artifactId>google-oauth-client</artifactId>
        <version>1.23.0</version>
    </dependency>

    <dependency>
        <groupId>com.google.oauth-client</groupId>
        <artifactId>google-oauth-client-java6</artifactId>
        <version>1.23.0</version>
    </dependency>

    <dependency>
        <groupId>com.google.oauth-client</groupId>
        <artifactId>google-oauth-client-jetty</artifactId>
        <version>1.23.0</version>
    </dependency>

    <dependency>
        <groupId>com.amazonaws</groupId>
        <artifactId>aws-java-sdk</artifactId>
        <version>1.11.269</version>
    </dependency>

    <dependency>
        <groupId>org.apache.httpcomponents</groupId>
        <artifactId>httpclient</artifactId>
        <version>4.5.2</version>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-databind</artifactId>
        <version>2.6.7.1</version>
        <scope>compile</scope>
    </dependency>

    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-annotations</artifactId>
        <version>2.6.0</version>
    </dependency>
    <dependency>
        <groupId>com.fasterxml.jackson.core</groupId>
        <artifactId>jackson-core</artifactId>
        <version>2.6.7</version>
    </dependency>

</dependencies>

1 个答案:

答案 0 :(得分:0)

将此添加到您的pom.xml

<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>${oauth.version}</version>
</dependency>
<properties>
        <oauth.version>2.3.3.RELEASE</oauth.version>
</properties>

我希望这可能有用。