Micronaut+ vertx+测试范围
如何使用Vert.x和TestContainers配置Micronaut应用?我正在尝试:
application-test.yml
datasources:
default:
url: jdbc:tc:mysql:8:///db
driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver
vertx:
mysql:
client:
uri: jdbc:tc:mysql:8:///db
使用micronaut-data-jdbc
进行测试,但使用micronaut-vertx-mysql-client
不使用工作:
错误:
消息:无法解析无效连接URI:JDBC:TC:MySQL:8:/// DB
我对TesteContainers并不熟悉,但似乎并没有出现使用固定端口,所以我不知道如何配置连接URI。
谢谢!
How do I configure Micronaut app using Vert.x and testcontainers? I'm trying:
application-test.yml
datasources:
default:
url: jdbc:tc:mysql:8:///db
driverClassName: org.testcontainers.jdbc.ContainerDatabaseDriver
vertx:
mysql:
client:
uri: jdbc:tc:mysql:8:///db
Tests with micronaut-data-jdbc
work, but with micronaut-vertx-mysql-client
not work:
Error:
Message: Cannot parse invalid connection URI: jdbc:tc:mysql:8:///db
I'm not very familiar with testecontainers, but it seems like it doesn't come up with a fixed port, so I don't know how to configure the connection URI.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
micronaut-vertx-mysql-client
不支持TestContainers JDBC URL方案(如果没有其他日志),这可能是一个问题。在这种情况下,我建议使用而不是特殊的JDBC URL。
It might be a problem that
micronaut-vertx-mysql-client
does not support the Testcontainers JDBC URL scheme (hard to say without further logs).In this case, I would suggest to use Testcontainers with database container objects instead of the special JDBC URL.
我有一个解决方案:
Micronaut + JDBC Hikari + Vertx mysql客户端 + Flyway mysql
帮助链接:
https://dev.to/major13ua/micronaut-integration-testing-testing-using-testcontainers-2e30
https://github.com/major.com/major13ua/micronaut-tc/micronaut-tc/blob/blob/main/main/src/src/test。 /java/com/example/testcontainer/controller/democontrollertest.java
I got a solution to the problem:
Micronaut + jdbc hikari + vertx mysql client + flyway mysql
Help links:
https://dev.to/major13ua/micronaut-integration-testing-using-testcontainers-2e30
https://github.com/major13ua/micronaut-tc/blob/main/src/test/java/com/example/testcontainer/controller/DemoControllerTest.java