Skip to content

Unable to load ApplicationContext after upgrading to asyncer #131

@guanyou-git

Description

@guanyou-git

Summary

Am unable to run tests and get the following error, more information here: https://stackoverflow.com/questions/76684680/upgraded-from-miku-to-asyncer-r2dbc-facing-autoconfigure-error-when-compiling

Detailed description

In my test, I have @SpringBootTest @AutoConfigureTestDatabase, and am getting the following error

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.r2dbc.core.DatabaseClient' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}

I updated my maven pom.xml, and updated my ConnectionFactory to the asyncer programmatic implementation

Old

@Configuration
@EnableR2dbcRepositories
public class MySqlConnectionFactories extends AbstractR2dbcConfiguration {
  
  @Value("${spring.datasource.host}")
  public String host;
  
  @Value("${spring.datasource.db}")
  public String db;
  
  @Value("${spring.datasource.username}")
  public String userName;

  @Value("${spring.datasource.password}")
  public String password;

  @Override
  @Bean
  public ConnectionFactory connectionFactory() {
    return MySqlConnectionFactory.from(
      MySqlConnectionConfiguration.builder()
        .host(host)
        .database(db)
        .username(userName)
        .password(password)
        .sslMode(SslMode.VERIFY_IDENTITY)
        .tlsVersion(TlsVersions.TLS1_2)
        .port(3306)
        .tcpKeepAlive(true)
        .tcpNoDelay(true)
        .build());
  }
}

New

@Configuration
@EnableR2dbcRepositories
public class MySqlConnectionFactories extends AbstractR2dbcConfiguration {
  
  @Value("${spring.datasource.host}")
  public String host;
  
  @Value("${spring.datasource.db}")
  public String db;
  
  @Value("${spring.datasource.username}")
  public String userName;

  @Value("${spring.datasource.password}")
  public String password;

  @Override
  @Bean
  public ConnectionFactory connectionFactory() {
    ConnectionFactoryOptions options = ConnectionFactoryOptions.builder()
        .option(ConnectionFactoryOptions.DRIVER, "mysql")
        .option(ConnectionFactoryOptions.HOST, host)
        .option(ConnectionFactoryOptions.USER, userName)
        .option(ConnectionFactoryOptions.PORT, 3306)
        .option(ConnectionFactoryOptions.PASSWORD, password)
        .option(ConnectionFactoryOptions.DATABASE, db)
        .option(Option.valueOf("sslMode"), SslMode.VERIFY_IDENTITY)
        .option(Option.valueOf("tlsVersion"), TlsVersions.TLS1_2)
        .option(Option.valueOf("tcpKeepAlive"), true) // optional, default false
        .option(Option.valueOf("tcpNoDelay"), true) // optional, default false
        .build();
    return ConnectionFactories.get(options);
  }
}

Relevant context

Checklist

  • [ Yes ] I have searched the existing issues to make sure my question has not been asked before
  • [ Yes] I have provided all the necessary information and context to help answer my question
  • [ Yes ] I have read the documentation and/or README for this project (if applicable)

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions