Spring security cucumber测试、jhipster和oauth:未找到ClientRegistration存储库bean

Spring security cucumber测试、jhipster和oauth:未找到ClientRegistration存储库bean,spring-security,oauth,cucumber,jhipster,spring-security-oauth2,Spring Security,Oauth,Cucumber,Jhipster,Spring Security Oauth2,当我将khipster项目配置为使用oauth2时,我在khipster项目中运行Cucumber测试(我也可以用jhipster复制它)时遇到问题 我使用以下配置文件(我称之为mono.jdl)创建项目: 我使用命令生成项目:khipster import jdl mono.jdl 我创建了一个非常简单的黄瓜测试。我创建了一个功能文件(src/test/features/kuku/kuku.feature): 以及包含步骤的文件(src/test/kotlin/com/example/hell

当我将khipster项目配置为使用oauth2时,我在khipster项目中运行Cucumber测试(我也可以用jhipster复制它)时遇到问题

我使用以下配置文件(我称之为mono.jdl)创建项目:

我使用命令生成项目:
khipster import jdl mono.jdl

我创建了一个非常简单的黄瓜测试。我创建了一个功能文件(src/test/features/kuku/kuku.feature):

以及包含步骤的文件(src/test/kotlin/com/example/helloworld/cucumber/stepdefs/KukuStepDefs.kt):

我尝试使用命令
/mvnw integration test
运行集成测试。但是,它会失败,并出现以下错误:

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of constructor in com.example.helloworld.web.rest.LogoutResource required a bean of type 'org.springframework.security.oauth2.client.registration.ClientRegistrationRepository' that could not be found.

The following candidates were found but could not be injected:
    - Bean method 'clientRegistrationRepository' in 'OAuth2ClientRegistrationRepositoryConfiguration' not loaded because OAuth2 Clients Configured Condition registered clients is not available


Action:

Consider revisiting the entries above or defining a bean of type 'org.springframework.security.oauth2.client.registration.ClientRegistrationRepository' in your configuration.
如何解决此问题?

解决方案是查找CucumberContextConfiguration类。它包含这样的注释:

@ContextConfiguration(classes = [HelloworldApp::class])
我们必须将其改为:

import com.example.helloworld.config.TestSecurityConfiguration
(...)
@ContextConfiguration(classes = [HelloworldApp::class, TestSecurityConfiguration::class])
***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of constructor in com.example.helloworld.web.rest.LogoutResource required a bean of type 'org.springframework.security.oauth2.client.registration.ClientRegistrationRepository' that could not be found.

The following candidates were found but could not be injected:
    - Bean method 'clientRegistrationRepository' in 'OAuth2ClientRegistrationRepositoryConfiguration' not loaded because OAuth2 Clients Configured Condition registered clients is not available


Action:

Consider revisiting the entries above or defining a bean of type 'org.springframework.security.oauth2.client.registration.ClientRegistrationRepository' in your configuration.
@ContextConfiguration(classes = [HelloworldApp::class])
import com.example.helloworld.config.TestSecurityConfiguration
(...)
@ContextConfiguration(classes = [HelloworldApp::class, TestSecurityConfiguration::class])