当前位置: 首页 > 知识库问答 >
问题:

Grails 3.1.10将spring-boot-starter-tomcat插件从war生成中排除

龙承德
2023-03-14

如果我将“spring-boot-starter-tomcat”插件依赖项集保留在gradle构建文件中进行编译,那么在部署到独立的Tomcat7服务器时,我会得到以下错误消息:

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

如果我将依赖关系更改为“提供”,我可以部署到Tomcat,但在IntelliJ IDEA15中运行或调试时会出现以下错误:

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容器中?

共有1个答案

姜俊民
2023-03-14

通过将依赖项更改为Provide,并使用“Grails”运行/调试配置,而不是使用Idea15创建项目时设置的“Application”配置,解决了这个问题。

 类似资料:
  • 我正在努力学习spring boot,我注意到有两种选择。 > spring-boot-starter-web-根据文档,它支持全栈web开发,包括Tomcat和web-mvc spring-Boot-Starter-Tomcat 既然#1支持Tomcat,为什么要使用#2呢? 有什么不同? 谢谢

  • 我正在使用spring boot,我想将一个rest API war文件部署到tomcat服务器中。tomcat服务器日志中没有错误,但当我调用任何endpoint时,我得到的是404“not found”,而我从tomcat服务器得到的是相同的。 java版本:8。tomcat版本:9。 也许我错过了什么,下面是我的代码示例: Pom: 2.application.java

  • 我们面临的问题是关于大小,我们意识到spring-boot-started占用了大量MB,而我们有另一个应用程序只使用:和,大小从50MB跳到10MB。 假设我们只使用Tomcat,除了使用的开发之外,如果删除会发生什么?我是否可以拥有一个只有和但仍然能够在开发过程中使用的应用程序?

  • 问题内容: 由于传递依赖关系,我的战争被xml-apis和xerces jar填充。我尝试按照参考页上有关maven-war- plugin的说明进行操作,但是它不起作用。 我究竟做错了什么 ?如果很重要,我发现我正在使用的maven-war-plugin版本为2.1-alpha-1 问题答案: 您可以将这些依赖项标记为已提供: 这样,maven会将它们添加到编译类路径中,但不会打包它们。假定它们

  • 我正在尝试将带有WAR打包的Spring Boot应用程序部署到。应用程序部署成功,但是,当我尝试访问endpoint时,它导致404找不到。 WAR文件:application.WAR Tomcat文件夹包含以下内容和(Angular)具有 正如这里所讨论的,我添加了一个类,它扩展了,如下所示 在pom.xml中,我为spring-boot-starter-tomcat、tomcat-embed

  • 我已经做了一个maven Spring boot(REST)项目,它有3个子模块(一、api二、实现和三、服务模块)。 主方法(@SpringBootApplication)位于项目的根目录中。RESTWeb服务在IDE中运行良好,但maven不允许我将此项目打包为war并部署到外部tomcat。 为了解决这个问题,我添加了一个新模块,并在其中添加了其他模块的依赖项,并将其打包为war(通过添加m