Closed huahouye closed 2 years ago
r2dbc-querydsl-lombok-mapstruct % mvn clean test
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] r2dbc-querydsl-lombok-mapstruct/src/test/java/com/example/demo/repository/UserRepositoryTest.java:[3,38] cannot find symbol
symbol: class QUser
location: package com.example.demo.domain
[ERROR] r2dbc-querydsl-lombok-mapstruct/src/test/java/com/example/demo/repository/UserRepositoryTest.java:[3,1] static import only from classes and interfaces
[INFO] 2 errors
I get the same error when running from terminal, Intellij IDEA build or internal IDEA Maven compiler.
@lpandzic sorry for bothering you, I restructured the simple project's code, please git pull
new code on the same branch infobip-spring-data-r2dbc-querydsl-h2-not-work
, and then you can run command mvn clean test spring-boot:run
.
It will work at this time because I comment out this line here.
According to doc R2DBC module setup I try to use new base repository but it seems not work.
public interface UserRepository extends QuerydslR2dbcRepository<User, UUID> {
}
@DataR2dbcTest
is not compatible with Infobip Spring Data Querydsl because of this part, as stated in annotation javadoc:
Annotation that can be used for a R2DBC test that focuses only on Data R2DBC components.
Using this annotation will disable full auto-configuration and instead apply only configuration relevant to Data R2DBC tests.
When using JUnit 4, this annotation should be used in combination with @RunWith(SpringRunner.class).
So infobip-spring-data-r2dbc-querydsl-boot-starter
auto configuration is not applied. I've tried running your project in debug mode and none of auto configuration classes from infobip-spring-data-r2dbc-querydsl-boot-starter
are invoked.
So one solution would be to use full spring context for your tests by removing @DataR2dbcTest
from your tests and instead adding something like
@SpringBootTest(classes = R2dbcQuerydslLombokMapstructApplication.class)
By adding @ImportAutoConfiguration(classes = { QuerydslR2dbcRepositoriesAutoConfiguration.class })
makes junit test work. I have committed all test code to my sample project if someone else needs it. thank you for tips.
Hi @lpandzic, I created an example here (note the branch is
infobip-spring-data-r2dbc-querydsl-h2-not-work
), Just runUserRepositoryTest
junit test, and then can see exceptions liks below: