最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

java - BeanCreationException in SpringBoot - Stack Overflow

programmeradmin6浏览0评论

I have two classes extending the same parent class; AbstractVaultConfiguration. My base classes @override the same two methods from AbstractVaultConfiguration which are clientAuthentication and and sessionManager.

The AbstractVaultConfiguration class is part of Spring Vault, which provides integration with HashiCorp Vault for Spring applications.

To use AbstractVaultConfiguration, I have included the Spring Vault dependency.

<dependency>
    <groupId>.springframework.vault</groupId>
    <artifactId>spring-vault-core</artifactId>
    <version>3.1.2</version>  <!-- Use the latest version -->
</dependency>

This is the error obtained:

.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionManager' defined in class path resource [abc.class]: No matching factory method found on class [abc.MsConfig]: factory bean 'mssConfig'; factory method 'sessionManager()'. Check that a method with the specified name exists and that it is non-static.

Example:

@Configuration
public class A extends AbstractVaultConfiguration{
    @Override
    public VaultEndpoint vaultEndpoint(){
        // Some Custom Implementation
        ...
    }

    @Override
    @Bean
    public ClientAuthentication clientAuthentication(){
        // Some Custom Implementation
        ...
    }
    @Override
    public SessionManager sessionManager(){
        // Some Custom Implementation
        ...
    }
}

@Configuration
public class B extends AbstractVaultConfiguration{
    @Override
    public VaultEndpoint vaultEndpoint(){
        // Some Custom Implementation
        ...
    }

    @Override
    @Bean(name = "customClientAuthentication")
    public ClientAuthentication clientAuthentication(){
        // Some Custom Implementation
        ...
    }

    @Override
    @Bean(name = "customSessionManager")
    public SessionManager sessionManager(){
        // Some Custom Implementation
        ...
    }
}

I have tried removing @Override and changing the method names to customClientAuthentication and customSessionManager in class B. When I do this the build is successful and my code works as expected, however the same fails in my pod. I am using java 17 temurin.

发布评论

评论列表(0)

  1. 暂无评论