【问题标题】:Grails 3.1.10 exclude spring-boot-starter-tomcat plugin from war generationGrails 3.1.10 从战争生成中排除 spring-boot-starter-tomcat 插件
【发布时间】:2016-12-24 21:02:53
【问题描述】:

如果我在 gradle 构建文件中将“spring-boot-starter-tomcat”插件依赖项设置为 compile,在部署到独立 Tomcat 7 服务器时会收到以下错误消息:

INFO: validateJarFile(/usr/share/tomcat/webapps/ROOT/WEB-INF/lib/tomcat-embed-core-8.0.36.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/servlet/Servlet.class
Aug 18, 2016 2:51:19 AM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(/usr/share/tomcat/webapps/ROOT/WEB-INF/lib/tomcat-embed-el-8.0.36.jar) - jar not loaded. See Servlet Spec 3.0, section 10.7.2. Offending class: javax/el/Expression.class

如果我将依赖项更改为 provided,我可以部署到 Tomcat,但尝试在 IntelliJ IDEA 15 中运行或调试时会出现以下错误:

ERROR org.springframework.boot.SpringApplication - Application startup failed
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [orderserver.Application]; nested exception is java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport
...
Caused by: java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport
...
Caused by: java.lang.NoClassDefFoundError: javax/servlet/ServletContext
...
Caused by: java.lang.ClassNotFoundException: javax.servlet.ServletContext

如何在生成 war 文件时排除这些依赖项,同时保留在 IDEA 中运行/调试的能力?

有没有一种方法可以生成一个嵌入了 Tomcat 的单一 war 文件,用于独立执行,也可以部署到 Tomcat 容器中?

【问题讨论】:

  • 我们在 grailsVersion=3.1.4 项目中使用provided,它在 IDE 中运行流畅(IntelliJ IDEA 2016.1.3 Build #IU-145.1617,于 6 月 3 日构建, 2016) 或生产 Tomcat。确定不是tomcat版本不匹配的问题?
  • @Michal_Szulc 是的,这是 tomcat 版本的问题,因为我在生产中部署到 Tomcat 7,但是当我将依赖项更改为“提供”时,我无法再在 IDEA 中运行。

标签: grails gradle spring-boot


【解决方案1】:

通过将依赖项更改为 provided 并使用“Grails”运行/调试配置而不是使用 IDEA 15 创建项目时设置的“应用程序”配置来解决此问题。

【讨论】:

    猜你喜欢
    • 2014-12-31
    • 2012-11-21
    • 2015-10-28
    • 2011-04-25
    • 2017-12-03
    • 2019-03-21
    • 1970-01-01
    • 1970-01-01
    • 2016-01-29
    相关资源
    最近更新 更多