1

I am upgrading spring boot from 2.6.6 to 2.7.1 and running into r2dbc-mysql error.

With Spring boot 2.6.6, I am using r2dbc-mysql.

runtimeOnly 'dev.miku:r2dbc-mysql'

Getting compilation error after upgrading Spring boot to 2.7.1.

So, commented the above from build.gradle and getting the error below at runtime.

Caused by: java.lang.IllegalStateException: Unable to create a ConnectionFactory for 'ConnectionFactoryOptions{options={database=test, host=app-dev-mysql.sdferf1234.us-east-2.rds.amazonaws.com, driver=mysql, password=REDACTED, protocol=, port=3306, user=test}}'. Available drivers: [ pool ]
    at io.r2dbc.spi.ConnectionFactories.get(ConnectionFactories.java:143) ~[r2dbc-spi-0.9.1.RELEASE.jar:?]
    at org.springframework.boot.r2dbc.ConnectionFactoryBuilder$OptionsCapableWrapper.buildAndWrap(ConnectionFactoryBuilder.java:191) ~[spring-boot-2.7.1.jar:2.7.1]
    at org.springframework.boot.r2dbc.ConnectionFactoryBuilder$PoolingAwareOptionsCapableWrapper.buildAndWrap(ConnectionFactoryBuilder.java:207) ~[spring-boot-2.7.1.jar:2.7.1]
    at org.springframework.boot.r2dbc.ConnectionFactoryBuilder.build(ConnectionFactoryBuilder.java:177) ~[spring-boot-2.7.1.jar:2.7.1]
    at org.springframework.boot.autoconfigure.r2dbc.ConnectionFactoryConfigurations.createConnectionFactory(ConnectionFactoryConfigurations.java:68) ~[spring-boot-autoconfigure-2.7.1.jar:2.7.1]
    at org.springframework.boot.autoconfigure.r2dbc.ConnectionFactoryConfigurations$GenericConfiguration.connectionFactory(ConnectionFactoryConfigurations.java:121) ~[spring-boot-autoconfigure-2.7.1.jar:2.7.1]
    at jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104) ~[?:?]
    at java.lang.reflect.Method.invoke(Method.java:577) ~[?:?]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:213) ~[spring-beans-5.3.21.jar:5.3.21]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1160) ~[spring-context-5.3.21.jar:5.3.21]
    at org.springframework.data.r2dbc.config.AbstractR2dbcConfiguration.lookupConnectionFactory(AbstractR2dbcConfiguration.java:236) ~[spring-data-r2dbc-1.5.1.jar:1.5.1]
user1578872
  • 7,808
  • 29
  • 108
  • 206

2 Answers2

1

Try with implementation group: 'dev.miku', name: 'r2dbc-mysql', version: '0.8.2.RELEASE' instead of runtimeOnly 'dev.miku:r2dbc-mysql', I had the same issue and it worked for me.

km369
  • 26
  • 3
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 08 '22 at 14:31
0

user1578872. As the maintainer of io.asyncer:r2dbc-mysql, I would like to inform you that the root cause of the issue you're facing is that Spring Boot 2.7.1 uses r2dbc-spi:0.9.1.RELEASE, whereas dev.miku:r2dbc-mysql:0.8.2 supports r2dbc-spi:0.8.*. I suggest you switch to using io.asyncer:r2dbc-mysql:0.9.2, which supports r2dbc-spi:0.9.1.RELEASE and is the official successor to dev.miku:r2dbc-mysql.

below is the current compatibility table

spring-boot-starter-data-r2dbc spring-data-r2dbc r2dbc-spi r2dbc-mysql(recommended)
3.0.* 3.0.* 1.0.0.RELEASE io.asyncer:r2dbc-mysql:1.0.1
2.7.* 1.5.* 0.9.1.RELEASE io.asyncer:r2dbc-mysql:0.9.2
2.6.* and below 1.4.* and below 0.8.6.RELEASE dev.miku:r2dbc-mysql:0.8.2

Please make sure to use the appropriate version of r2dbc-mysql base don your current Spring boot version.

For more information, you can visit the official repository at https://github.com/asyncer-io/r2dbc-mysql. If you have any further questions or run into any issues, please feel free to create an issue in the repository. We're here to help!

Thank you!

jchrys
  • 11
  • 2