【问题标题】:Could Zuul-Server SNAPSHOT be broken?Zuul-Server SNAPSHOT 会被破坏吗?
【发布时间】:2015-03-03 17:51:57
【问题描述】:

我正在构建一个在使用 Spring Cloud 快照构建之前正在运行的项目。除了 Zuul Server,一切似乎都正常。我收到以下异常:

Caused by: javax.validation.ValidationException: Unable to instantiate Configuration.
    at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:279)
    at org.springframework.validation.beanvalidation.LocalValidatorFactoryBean.afterPropertiesSet(LocalValidatorFactoryBean.java:223)
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor$Jsr303ValidatorFactory.run(ConfigurationPropertiesBindingPostProcessor.java:361)
    at org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor.afterPropertiesSet(ConfigurationPropertiesBindingPostProcessor.java:174)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1625)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1562)
    ... 28 more
Caused by: javax.validation.ValidationException: HV000183: Unable to load 'javax.el.ExpressionFactory'. Check that you have the EL dependencies on the classpath
    at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.<init>(ResourceBundleMessageInterpolator.java:172)
    at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.<init>(ResourceBundleMessageInterpolator.java:118)
    at org.hibernate.validator.internal.engine.ConfigurationImpl.<init>(ConfigurationImpl.java:110)
    at org.hibernate.validator.internal.engine.ConfigurationImpl.<init>(ConfigurationImpl.java:86)
    at org.hibernate.validator.HibernateValidator.createGenericConfiguration(HibernateValidator.java:41)
    at javax.validation.Validation$GenericBootstrapImpl.configure(Validation.java:276)

这带来的是添加以下依赖:

<dependency>
    <groupId>javax.el</groupId>
    <artifactId>javax.el-api</artifactId>
    <version>2.2.4</version>
 </dependency>
 <dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>javax.el</artifactId>
    <version>2.2.4</version>
  </dependency>

这导致另一个异常:

   Caused by: java.lang.NoClassDefFoundError: org/springframework/web/client/RestTemplate

那时我放弃了修补我的 POM。然后我去克隆 GIT 上的 Zuul 项目。不幸的是,我遇到了同样的问题。

想法?

【问题讨论】:

    标签: spring-boot spring-cloud netflix-zuul


    【解决方案1】:

    zuul 服务器的 spring cloud 示例版本有同样的问题。在我添加了 spring boot 启动器 web 和执行器后,它就消失了。

    【讨论】:

      【解决方案2】:

      这只是依赖结构的变化。我什至不知道你为什么需要一个 EL 实现,但 tomcat-embed-el 可能是最好的一个。另一个类来自spring-web。

      【讨论】:

      • 谢谢戴夫。添加 tomcat-embed-el 仍然会导致 java.lang.NoClassDefFoundError: org/springframework/web/client/RestTemplate.
      • 这就是为什么我说你需要 spring-web。
      • 这个类中的大多数应用程序已经在使用 spring-boot-starter-web ,其中包含所有内容(这就是为什么还没有样本提出这个问题的原因)。
      • 我尝试了添加 spring-web、spring-boot-starter-web 和 tomcat-embed-el 的组合。我一直得到:java.lang.NoClassDefFoundError: org/springframework/boot/actuate/endpoint/mvc/MvcEndpoint。我正在使用 Github Zuul-Server 项目进行此测试。
      • 非常感谢。以下两个依赖项解决了这个问题:spring-boot-starter-web、spring-boot-actuator。请考虑将它们添加到 github 中的 spring cloud 示例中。
      猜你喜欢
      • 2013-12-02
      • 2019-02-23
      • 1970-01-01
      • 1970-01-01
      • 2013-10-31
      • 2012-07-24
      • 2011-09-19
      • 1970-01-01
      相关资源
      最近更新 更多