有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

带有Gradle的java spring引导安全oauth 2不工作无法处理配置类的导入候选项

我正在尝试创建一个基于Gradle的spring boot安全项目,该项目实现OAUTH 2。我已经附加了我的构建。gradle文件和AuthorizationServerConfig文件在启动服务时失败

建造。格拉德尔:

buildscript {
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.3.RELEASE")
    }
}

apply plugin: 'jacoco'
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

bootJar {
    baseName = 'oauth2-example-SB'
    version =  '0.0.1'
}

repositories {
    mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
    compile('org.springframework.boot:spring-boot-starter-web')
    compile('org.springframework.boot:spring-boot-starter-data-jpa:2.0.3.RELEASE')
    compile('org.springframework.boot:spring-boot-starter-security:2.0.3.RELEASE')
    compile('org.springframework.security.oauth:spring-security-oauth2:2.0.3.RELEASE')
    compile('mysql:mysql-connector-java:8.0.13')
    compile('commons-dbcp:commons-dbcp:1.4')
    compile('org.projectlombok:lombok:1.16.20')
    testCompile('junit:junit')
}

授权服务器配置

@Configuration
@EnableAuthorizationServer
public class AuthorisationServerConfig extends AuthorizationServerConfigurerAdapter{
    static final String CLIEN_ID = "techares-client";
    static final String GRANT_TYPE = "password";
    static final String CLIENT_SECRET = "$2a$04$e/c1/RfsWuThaWFCrcCuJeoyvwCV0URN/6Pn9ZFlrtIWaU/vj/BfG";
    static final String AUTHORIZATION_CODE = "authorization_code";
    static final String REFRESH_TOKEN = "refresh_token";
    static final String IMPLICIT = "implicit";
    static final String SCOPE_READ = "read";
    static final String SCOPE_WRITE = "write";
    static final String TRUST = "trust";
    static final int ACCESS_TOKEN_VALIDITY_SECONDS = 1*60*60;
    static final int FREFRESH_TOKEN_VALIDITY_SECONDS = 6*60*60;

    @Autowired
    private TokenStore tokenStore;

    @Autowired
    private AuthenticationManager authenticationManager;

    @Override
    public void configure(ClientDetailsServiceConfigurer configurer) throws Exception {

        configurer
                .inMemory()
                .withClient(CLIEN_ID)
                .secret(CLIENT_SECRET)
                .authorizedGrantTypes(GRANT_TYPE, AUTHORIZATION_CODE, REFRESH_TOKEN, IMPLICIT )
                .scopes(SCOPE_READ, SCOPE_WRITE, TRUST)
                .accessTokenValiditySeconds(ACCESS_TOKEN_VALIDITY_SECONDS).
                refreshTokenValiditySeconds(FREFRESH_TOKEN_VALIDITY_SECONDS);
    }

    @Override
    public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception {
        endpoints.tokenStore(tokenStore)
                .authenticationManager(authenticationManager);
    }
}

我正在尝试启动spring启动应用程序,但遇到以下异常

2019-06-30 08:42:42.079信息26356---[main]com。春天MainApplication:在Ares MacBook Pro上启动MainApplication。本地,PID 26356(/eclipse workspace/ds_alg/oauth2示例SB/bin/main由arun在/eclipse workspace/ds_alg/oauth2示例SB中启动) 2019-06-30 08:42:42.081信息26356---[main]com。春天主应用程序:未设置活动配置文件,返回默认配置文件:默认 2019-06-30 08:42:42.123信息26356---[main]配置ServletWebServerApplicationContext:刷新组织。springframework。靴子网状物servlet。上下文AnnotationConfigServletWebServerApplicationContext@618b19ad:启动日期[Sun Jun 30 08:42:42 IST 2019];上下文层次结构的根 2019-06-30 08:42:42.243警告26356---[main]ConfigServletWebServerApplicationContext:上下文初始化期间遇到异常-取消刷新尝试:org。springframework。豆。工厂BeanDefinitionStoreException:无法处理配置类[com.spring.configuration.AuthorizationServerConfig]的导入候选项;嵌套的异常是java。木卫一。FileNotFoundException:无法打开类路径资源[org/springframework/security/config/annotation/authentication/configurers/globalaauthenticationconfigureradapter.class],因为它不存在 2019-06-30 08:42:42.497错误26356---[main]o.s.boot。SpringApplication:应用程序运行失败

组织。springframework。豆。工厂BeanDefinitionStoreException:无法处理配置类[com.spring.configuration.AuthorizationServerConfig]的导入候选项;嵌套的异常是java。木卫一。FileNotFoundException:无法打开类路径资源[org/springframework/security/config/annotation/authentication/configurers/globalaauthenticationconfigureradapter.class],因为它不存在 在org。springframework。上下文注释。ConfigurationClassParser。processImports(ConfigurationClassParser.java:648)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。上下文注释。ConfigurationClassParser。doProcessConfigurationClass(ConfigurationClassParser.java:303)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。上下文注释。ConfigurationClassParser。processConfigurationClass(ConfigurationClassParser.java:245)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。上下文注释。ConfigurationClassParser。解析(ConfigurationClassParser.java:194)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。上下文注释。ConfigurationClassParser。doProcessConfigurationClass(ConfigurationClassParser.java:296)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。上下文注释。ConfigurationClassParser。processConfigurationClass(ConfigurationClassParser.java:245)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。上下文注释。ConfigurationClassParser。解析(ConfigurationClassParser.java:202)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。上下文注释。ConfigurationClassParser。解析(ConfigurationClassParser.java:170)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。上下文注释。配置类后处理器。processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:316)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。上下文注释。配置类后处理器。后处理BeanDefinitionRegistry(ConfigurationClassPostProcessor.java:233)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。上下文支持后处理器注册Legate。invokeBeanDefinitionRegistryPostProcessors(postprocessorregistrationelegate.java:273)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。上下文支持后处理器注册Legate。invokeBeanFactoryPostProcessors(postProcessorRegistrationLegate.java:93)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。上下文支持AbstractApplicationContext。invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:694)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。上下文支持AbstractApplicationContext。刷新(AbstractApplicationContext.java:532)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。靴子网状物servlet。上下文ServletWebServerApplicationContext。刷新(ServletWebServerApplicationContext.java:140)~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] 在org。springframework。靴子SpringApplication。刷新(SpringApplication.java:759)~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] 在org。springframework。靴子SpringApplication。refreshContext(SpringApplication.java:395)~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] 在org。springframework。靴子SpringApplication。运行(SpringApplication.java:327)~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] 在org。springframework。靴子SpringApplication。运行(SpringApplication.java:1255)~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] 在org。springframework。靴子SpringApplication。运行(SpringApplication.java:1243)~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] 在com。春天主应用程序。main(MainApplication.java:10)~[main/:na] 原因:java。木卫一。FileNotFoundException:无法打开类路径资源[org/springframework/security/config/annotation/authentication/configurers/globalaauthenticationconfigureradapter.class],因为它不存在 在org。springframework。果心木卫一。类路径资源。getInputStream(ClassPathResource.java:180)~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。果心类型课堂阅读。SimpleMetadataReader。(SimpleMetadataReader.java:51)~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。果心类型课堂阅读。SimpleMetadataReaderFactory。getMetadataReader(SimpleMetadataReaderFactory.java:103)~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。靴子类型课堂阅读。ConcurrentReferenceCacheMetadataReaderFactory。createMetadataReader(ConcurrentReferenceCacheMetadataReaderFactory.java:88)~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] 在org。springframework。靴子类型课堂阅读。ConcurrentReferenceCacheMetadataReaderFactory。getMetadataReader(ConcurrentReferenceCacheMetadataReaderFactory.java:75)~[spring-boot-2.0.3.RELEASE.jar:2.0.3.RELEASE] 在org。springframework。果心类型课堂阅读。SimpleMetadataReaderFactory。getMetadataReader(SimpleMetadataReaderFactory.java:81)~[spring-core-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。上下文注释。ConfigurationClassParser。asSourceClass(ConfigurationClassParser.java:734)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。上下文注释。ConfigurationClassParser$SourceClass。getSuperClass(ConfigurationClassParser.java:950)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。上下文注释。ConfigurationClassParser。doProcessConfigurationClass(ConfigurationClassParser.java:333)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。上下文注释。ConfigurationClassParser。processConfigurationClass(ConfigurationClassParser.java:245)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。上下文注释。ConfigurationClassParser。processMemberClasses(ConfigurationClassParser.java:362)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEA[东南] 在org。springframework。上下文注释。ConfigurationClassParser。doProcessConfigurationClass(ConfigurationClassParser.java:265)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。上下文注释。ConfigurationClassParser。processConfigurationClass(ConfigurationClassParser.java:245)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE] 在org。springframework。上下文注释。ConfigurationClassParser。processImports(ConfigurationClassParser.java:638)~[spring-context-5.0.7.RELEASE.jar:5.0.7.RELEASE

请提出一些解决问题的想法


共 (0) 个答案