Quarkus扩展(io.quarkus:quarkus-spring-data-jpa)存储库无法返回字符串集合。

huangapple 未分类评论45阅读模式
英文:

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&lt;Dictionary, UUID&gt; {

    @Query(&quot;select distinct(d.type) from Dictionary d order by d.type&quot;)
    List&lt;String&gt; 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.

huangapple
  • 本文由 发表于 2020年4月7日 03:30:41
  • 转载请务必保留本文链接:https://java.coder-hub.com/61067524.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定