SpringBoot Application 由于 servlet-API 而无法启动



你好,首先对不起我的英语。我正在尝试启动我的 springboot 应用程序,但由于 servlet-api 3.1 和旧版本冲突,它无法启动,但我不知道哪个依赖项为此发生冲突,希望有人可以帮助我。以下是我的pom文件详细信息:

<dependencies>
<dependency>  
<groupId>javax.servlet</groupId>  
<artifactId>javax.servlet-api</artifactId>  
<version>3.1.0</version>  
<scope>provided</scope>
</dependency> 
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>

这是我删除的 spring 依赖项,我使用的是 springboot 2.0.4 和 spring 5。

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>${jjwt.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.4.3</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>r05</version>
</dependency>
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.1.7</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.2</version>
</dependency>

<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4.5</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20090211</version>
</dependency>
<dependency>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>

<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>6.2.1</version>
<exclusions>  
<exclusion>  
<groupId>javax.servlet</groupId>  
<artifactId>servlet-api</artifactId>  
</exclusion>  
</exclusions>  
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.10.1</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.3</version>
<exclusions>  
<exclusion>  
<groupId>javax.servlet</groupId>  
<artifactId>servlet-api</artifactId>  
</exclusion>  
</exclusions>  
</dependency>
<dependency>
<groupId>org.ocpsoft.rewrite</groupId>
<artifactId>rewrite-servlet</artifactId>
<version>2.0.12.Final</version> <!-- or latest version -->
</dependency>
<dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>com.google.apis</groupId>
<artifactId>google-api-services-bigquery</artifactId>
<version>v2-rev265-1.21.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-servlet-starter</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jackson-starter</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-swagger-java-starter</artifactId>
<version>${camel.version}</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring-boot-starter</artifactId>
<version>${camel.version}</version>
</dependency>    

<dependency>
<groupId>pentaho-reporting-engine</groupId>
<artifactId>pentaho-reporting-engine-classic-core</artifactId>
<version>7.0.0.0-25</version>
</dependency>
<dependency>
<groupId>pentaho</groupId>
<artifactId>pentaho-database-model</artifactId>
<version>7.0.0.0-25</version>
</dependency>
<dependency>
<groupId>pentaho-reporting-engine</groupId>
<artifactId>pentaho-reporting-engine-classic-extensions</artifactId>
<version>7.0.0.0-25</version>
</dependency>
<dependency>
<groupId>pentaho-reporting-engine</groupId>
<artifactId>pentaho-reporting-engine-legacy-charts</artifactId>
<version>7.0.0.0-25</version>
</dependency> 
<dependency>
<groupId>jfree</groupId>
<artifactId>jfreechart</artifactId>
<version>1.0.13</version>
</dependency>
<dependency>
<groupId>jfree</groupId>
<artifactId>jcommon</artifactId>
<version>1.0.16</version>
</dependency>
<dependency>
<groupId>bsf</groupId>
<artifactId>bsf</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>bsh</groupId>
<artifactId>bsh</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libbase</artifactId>
<version>7.0.0.0-25</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libdocbundle</artifactId>
<version>7.0.0.0-25</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libfonts</artifactId>
<version>7.0.0.0-25</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libformat</artifactId>
<version>7.0.0.0-25</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libformula</artifactId>
<version>7.0.0.0-25</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libloader</artifactId>
<version>7.0.0.0-25</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libpixie</artifactId>
<version>7.0.0.0-25</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>librepository</artifactId>
<version>7.0.0.0-25</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libserializer</artifactId>
<version>7.0.0.0-25</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libxml</artifactId>
<version>7.0.0.0-25</version>
</dependency>
<dependency>
<groupId>pentaho-library</groupId>
<artifactId>libswing</artifactId>
<version>7.0.0.0-25</version>
</dependency> 
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-core</artifactId>
<version>7.0.0.0-25</version>
<exclusions>  
<exclusion> 
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</exclusion>
<exclusion>  
<groupId>javax.servlet</groupId>  
<artifactId>servlet-api</artifactId>  
</exclusion>  
</exclusions>
</dependency>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-engine</artifactId>
<version>7.0.0.0-25</version>
<exclusions>  
<exclusion> 
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</exclusion>
<exclusion>  
<groupId>javax.servlet</groupId>  
<artifactId>servlet-api</artifactId>  
</exclusion>  
</exclusions>
</dependency>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-ui-swt</artifactId>
<version>7.0.0.0-25</version>
<exclusions>  
<exclusion> 
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</exclusion>
<exclusion>  
<groupId>javax.servlet</groupId>  
<artifactId>servlet-api</artifactId>  
</exclusion>  
</exclusions>
</dependency>
<!-- Pivot4J dependencies -->
<dependency>
<groupId>org.pivot4j</groupId>
<artifactId>pivot4j-core</artifactId>
<version>0.9</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.20</version>
</dependency>
<dependency>
<groupId>org.olap4j</groupId>
<artifactId>olap4j</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
<dependency>
<groupId>org.bitbucket.b_c</groupId>
<artifactId>jose4j</artifactId>
<version>0.4.4</version>
</dependency>
<dependency>
<groupId>commons-dbutils</groupId>
<artifactId>commons-dbutils</artifactId>
<version>1.6</version>
</dependency>

</dependencies>
<repositories>
<repository>
<id>codelds</id>
<url>https://code.lds.org/nexus/content/groups/main-repo</url>
</repository>
<repository>
<id>googleapis</id>
<url>https://google-api-client-libraries.appspot.com/mavenrepo</url>
</repository>
<repository>
<id>pentaho-releases</id>
<url>http://nexus.pentaho.org/content/groups/omni</url>
</repository>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

这是我即将发布的错误消息:

Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.getVirtualServerName()Ljava/lang/String;
at org.apache.catalina.authenticator.AuthenticatorBase.startInternal(AuthenticatorBase.java:1122) ~[tomcat-embed-core-8.5.5.jar:8.5.5]
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) [tomcat-embed-core-8.5.5.jar:8.5.5]
... 10 common frames omitted

我遇到了类似的问题(Sprint Boot 1.5和Kettle 8(,我发现问题/冲突与水壶核心和水壶引擎有关。

我在这些依赖项中排除了 slf4j 和 servlet:

<!-- Pentaho Kettle -->
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-core</artifactId>
<version>${pentaho-kettle.version}</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-engine</artifactId>
<version>${pentaho-kettle.version}</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>

情况

我在使用 Spring Boot 2.2.6.RELEASE 的服务器应用程序时遇到了类似的问题,但这不是 Spring 引导的错误,而是我使用 Wiremock 进行测试,并在 IDE 中启动我的应用程序:

java.lang.NoSuchMethodError: javax.servlet.http.HttpServletRequest.getHttpServletMapping()Ljavax/servlet/http/HttpServletMapping;
at org.apache.catalina.core.ApplicationHttpRequest.setRequest(ApplicationHttpRequest.java:708)
at org.apache.catalina.core.ApplicationHttpRequest.<init>(ApplicationHttpRequest.java:114)
...
org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

我的应用程序即使在这些异常的情况下也能工作,但对于测试和调试,我不想有这些干扰,宁愿避免它们。

WireMock(例如 2.26.3(在内部使用 Jetty 9。但是 Jetty 不包括内部的 Servlet API 4 而是 3,而且似乎没有太大的进展,即使是 jetty 10/11 等 - 见 https://github.com/eclipse/jetty.project/issues/4578

集成开发环境启动

因此,当启动一个不会在运行时依赖关系和测试依赖关系之间自动分离的IDE时,您将在类路径中包含Jetty的Servlet 3 API!

服务器由 jar 启动

在我的集成测试中,我的应用程序仅使用运行时依赖项启动,我没有这些异常,因为没有 jetty 依赖项。

溶液

因此,就我而言,我有三种可能性来解决IDE启动的问题:

  • 在 IDE 启动配置中更改类路径顺序
  • 分离我的依赖项,以便用于服务器启动的项目在 IDE 中也没有依赖项,或者
  • 将弹簧启动 Web 启动依赖项从雄猫切换到码头...

就像@user1695936说的: 问题是mondrian包含一个旧版本的servlet-ap(v2.4(,它没有getVirtualServerName((方法。

用这个检查javax.servlet的依赖关系:

mvn dependency:tree -Dverbose -Dincludes=javax.servlet
pentaho:mondrian:jar:8.3.0.0-371:compile
|  +- javax.servlet:servlet-api:jar:2.4:compile
|  - javax.servlet:jsp-api:jar:2.0:compile

并排除旧版本,如下例所示:

<dependency>
<groupId>pentaho-kettle</groupId>
<artifactId>kettle-engine</artifactId>
<version>${pentaho-kettle.version}</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>

相关内容

  • 没有找到相关文章

最新更新