如何解决依赖版本冲突(NoSuchMethodError)

发布于 2024-11-27 01:14:55 字数 1072 浏览 2 评论 0原文

在我的 Spring 3.0.5 Web MVC 应用程序中,我定义了一个模型类,其属性用 @SafeHtml 注释。当 Spring 尝试验证此模型对象时,它会出现以下错误:

HTTP ERROR: 500

org.jsoup.Jsoup.isValid(Ljava/lang/String;Lorg/jsoup/safety/Whitelist;)Z
RequestURI=/guestbook/process-new-entry

Caused by:

java.lang.NoSuchMethodError: org.jsoup.Jsoup.isValid(Ljava/lang/String;Lorg/jsoup/safety/Whitelist;)Z
    at org.hibernate.validator.constraints.impl.SafeHtmlValidator.isValid(SafeHtmlValidator.java:62)
    at org.hibernate.validator.constraints.impl.SafeHtmlValidator.isValid(SafeHtmlValidator.java:34)
    at org.hibernate.validator.engine.ConstraintTree.validateSingleConstraint(ConstraintTree.java:278)
    ... (abbreviated)

我知道这是由于我没有使用正确版本的 Jsoup 造成的。 (我使用的是 0.2.2)在我使用的这个版本中,isValid() 的方法签名已更改或已被完全删除。因此,为了解决这个问题,我相信我应该使用不同版本的 Jsoup。我说得对吗?

假设,如果我想继续使用我当前使用的版本怎么办?其他需要更改版本的部分是什么?它是 Hibernate 验证器吗?

另外,有人可以建议一种方法来找出要使用的 Jsoup 版本吗? 通常如何解决此类错误?

最后一个问题是,行尾的“Z”字母是什么意思?我有时也会遇到其他信件。这些字母是什么意思?这有记录在任何地方吗?

预先感谢大家帮助我更好地理解应该如何解决这些版本差异,这样我将来就不需要浪费这么多时间了......干杯!

In my Spring 3.0.5 Web MVC application I have defined a model class with a property annotated with @SafeHtml. When Spring tries to validate this model object, it blows up with the following:

HTTP ERROR: 500

org.jsoup.Jsoup.isValid(Ljava/lang/String;Lorg/jsoup/safety/Whitelist;)Z
RequestURI=/guestbook/process-new-entry

Caused by:

java.lang.NoSuchMethodError: org.jsoup.Jsoup.isValid(Ljava/lang/String;Lorg/jsoup/safety/Whitelist;)Z
    at org.hibernate.validator.constraints.impl.SafeHtmlValidator.isValid(SafeHtmlValidator.java:62)
    at org.hibernate.validator.constraints.impl.SafeHtmlValidator.isValid(SafeHtmlValidator.java:34)
    at org.hibernate.validator.engine.ConstraintTree.validateSingleConstraint(ConstraintTree.java:278)
    ... (abbreviated)

I understand this is caused by my not using the right version of Jsoup. (I'm using 0.2.2) In this version I am using, the method signature for isValid() has changed or has been removed altogether. So to resolve this, I believe I should use a different version of Jsoup. Am I right?

Hypothetically, what if I wanted to keep using the version I am currently using - what is the other part that needs a change in version? Is it the Hibernate validator?

Also, can anyone suggest a way to find out which version of Jsoup to use? How do you usually resolve this kind of errors?

And, one final question, what does to "Z" letter at the end of the line mean? I sometimes come across other letters as well. What do these letters mean? Is this documented anywhere?

Thank you all in advance for helping me arrive at a better understanding of how these version discrepancies should be resolved, so I wouldn't need to waste so much of my time in the future... Cheers!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寻找我们的幸福 2024-12-04 01:14:55
  1. 是的
  2. 如果你想继续使用 Jsoup 0.2.2,你必须看看是否有一个版本的 hibernate-validator 可以与该版本一起使用,这似乎不太可能,因为我认为 @SafeHtml 约束是相当新的,或者你' d 必须看看是否可以修改源代码以使用该版本。
  3. 如果您想要 Hibernate 期望的 Jsoup 版本的明确答案,您可以检查您正在使用的验证器工件版本的 pom。它们可以在 maven 中心
  4. “Z”是原始布尔类型的类型描述符。 VM 规范有一个一个表,列出可能的值。
  1. Yes
  2. If you want to keep using Jsoup 0.2.2, you'd have to see if there's a version of hibernate-validator that will work with that version, which seems unlikely since I think the @SafeHtml constraint is pretty new, or you'd have to see if you can modify the source code to work with that version.
  3. If you want a definitive answer to which Jsoup version hibernate expects, you can check the pom of whichever version of the validator artifact you're using. They're easily available at maven central.
  4. "Z" is the type descriptor for the primitive boolean type. The VM spec has a table that lists the possible values.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文