如果我将"spring-boot-starter-tomcat"插件依赖项设置为gradle构建文件中的 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
如何在保留在IDEA中运行/调试的能力的同时从war文件生成中排除这些依赖项?
更好的是有一种生成单个war文件的方法,该文件嵌入了Tomcat以进行独立执行,也可以部署到Tomcat容器中吗?
1 回答
通过将依赖项更改为 provided 并使用"Grails"运行/调试配置而不是使用IDEA 15创建项目时设置的"Application"配置,解决了此问题 .