英文:
Quarkus extension (io.quarkus:quarkus-spring-data-jpa) repository can't return Collection of Strings
问题
我正在将我的服务从SpringBoot堆栈迁移到Quarkus。为什么以下代码在Quarkus中不起作用?这是一个bug吗?
public interface GenericDictionaryRepository extends
JpaRepository<Dictionary, UUID> {
@Query("select distinct(d.type) from Dictionary d order by d.type")
List<String> findAllTypes();
}
错误消息
io.quarkus.builder.BuildException: 构建失败:由于错误而构建失败
[error]: 构建步骤 io.quarkus.spring.data.deployment.SpringDataJPAProcessor#build 抛出异常:java.lang.IllegalStateException: java.lang.String 不是Quarkus索引的一部分
我的Gradle版本属性:
quarkusPluginVersion=1.3.1.Final
quarkusPlatformArtifactId=quarkus-universe-bom
quarkusPlatformGroupId=io.quarkus
quarkusPlatformVersion=1.3.1.Final
英文:
I'm migrating my service to Quarkus from SpringBoot stack.
Why the following code doesn't work in Quarkus? Is that a bug?
public interface GenericDictionaryRepository extends
JpaRepository<Dictionary, UUID> {
@Query("select distinct(d.type) from Dictionary d order by d.type")
List<String> findAllTypes();
}
Error message
io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[error]: Build step io.quarkus.spring.data.deployment.SpringDataJPAProcessor#build threw an exception: java.lang.IllegalStateException: java.lang.String was not part of the Quarkus index
My version properties for Gradle:
quarkusPluginVersion=1.3.1.Final
quarkusPlatformArtifactId=quarkus-universe-bom
quarkusPlatformGroupId=io.quarkus
quarkusPlatformVersion=1.3.1.Final
答案1
得分: 0
我遇到了相同的问题,这是一个方法命名问题。我不得不在 quarkus 的代码中设置断点,找出哪个方法拼写错误。
在我这里,方法是 findAllOrderByNameAsc
,当我使用 findAllByOrderByNameAsc
时,它就起作用了。
要调试应用程序,您需要执行命令 ./mvnw quarkus:dev -Ddebug -Dsuspend=true
,然后从您的 IDE 连接到远程。
希望能有所帮助。
英文:
I had the same problem and it was a method naming problem. I had to put a break point in the quarkus code to find what method was wrongly spelled.
In my case the method was findAllOrderByNameAsc
and when I used findAllByOrderByNameAsc
, it worked.
To debug the app you have to execute the command ./mvnw quarkus:dev -Ddebug -Dsuspend=true
and connect to remote from your IDE.
Hope it helps.
专注分享java语言的经验与见解,让所有开发者获益!
评论