Jdbi: 注释格式错误

创建于 2016-12-19  ·  6评论  ·  资料来源: jdbi/jdbi

调用init方法失败; 嵌套异常是 java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.skife.jdbi.v2.sqlobject.stringtemplate.UseStringTemplate3StatementLocator.errorListener()

如何解决这个问题?

最有用的评论

啊,我看到你解决了这个问题。 StringTemplate 库是可选的,因为只有特定功能(例如使用 ST 表达式)才需要它。 例如, @BindIn注释使用它们,因为不可能通过 JDBC API 提供in (:list)准备好的语句。

在 JDBI3 中,通过将 StringTemplate 功能移动到具有对 StringTemplate 的编译依赖性的特定模块来解决此问题。

所有6条评论

能否提供更详细的测试用例? 不幸的是,您的剪辑没有提供足够的信息来重现错误。

<strong i="5">@UseStringTemplate3StatementLocator</strong>
public interface UsersRepository {

    @SqlQuery("SELECT id FROM users WHERE phone IN (<phones>)")
    List<Long> find(@BindIn("phones") List<String> phones);
}

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration: Invocation of init method failed; nested exception is java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.skife.jdbi.v2.sqlobject.stringtemplate.UseStringTemplate3StatementLocator.errorListener()

所以
dbi().onDemand(UsersRepository.class);
不行

我已经将https://mvnrepository.com/artifact/org.antlr/stringtemplate/3.2.1添加到依赖项中,现在它可以工作了
但是为什么这个依赖没有包含在 jdbi 中呢?

您能否检查 StringTemplate 库(Maven 坐标org.antlr:stringtemplate )是否存在于您的类路径中? 如果有,是哪个版本?

啊,我看到你解决了这个问题。 StringTemplate 库是可选的,因为只有特定功能(例如使用 ST 表达式)才需要它。 例如, @BindIn注释使用它们,因为不可能通过 JDBC API 提供in (:list)准备好的语句。

在 JDBI3 中,通过将 StringTemplate 功能移动到具有对 StringTemplate 的编译依赖性的特定模块来解决此问题。

好,谢谢

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

agavrilov76 picture agavrilov76  ·  5评论

keith-miller picture keith-miller  ·  3评论

goxr3plus picture goxr3plus  ·  4评论

jimmyhmiller picture jimmyhmiller  ·  6评论

electrum picture electrum  ·  3评论