首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >由于servlet应用程序接口,SpringBoot应用程序未启动

由于servlet应用程序接口,SpringBoot应用程序未启动
EN

Stack Overflow用户
提问于 2018-09-06 19:28:47
回答 3查看 2.7K关注 0票数 3

大家好,首先为我的英语感到抱歉。我正在尝试启动我的springboot应用程序,但由于servlet-api 3.1和旧版本的冲突而无法启动,但我不知道哪个依赖项会因此而发生冲突,希望能有一些帮助。以下是我的pom文件详细信息:

代码语言:javascript
复制
<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>

下面是我使用Springboot2.0.4和Spring5删除的spring依赖项。

代码语言:javascript
复制
    <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>

这是我即将收到的错误消息:

代码语言:javascript
复制
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
EN

回答 3

Stack Overflow用户

发布于 2018-11-23 04:28:14

我遇到了类似的问题(Sprint Boot 1.5和Kettle 8),我发现问题/冲突是与kettle-core和kettle-engine有关的。

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

代码语言:javascript
复制
<!-- 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>
票数 1
EN

Stack Overflow用户

发布于 2020-05-07 19:07:20

情况

我在使用Spring Boot2.2.6.RELEASE的服务器应用程序中遇到了类似的问题,但这不是Spring boot的问题,而是我使用Wiremock进行测试并在集成开发环境中启动应用程序时遇到的问题:

代码语言:javascript
复制
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 API4而是3,而且似乎没有太多进展,即使是jetty 10/11等-参见https://github.com/eclipse/jetty.project/issues/4578

IDE启动

因此,当启动一个不能自动区分运行时依赖项和测试依赖项的IDE时,您的类路径中将包含Jetty包含的Servlet 3API!

通过jar启动服务器

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

解决方案

所以在我的例子中,我有三种可能的方法来解决IDE启动时的问题:

在集成开发环境中更改启动

  • 的类路径顺序启动我的依赖项,以便用于服务器启动的项目在集成开发环境中也不具有依赖项,或者将
  • 将Spring Boot Web start依赖项从tomcat切换为jetty ...
票数 1
EN

Stack Overflow用户

发布于 2019-08-29 22:39:30

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

使用以下命令检查与javax.servlet的依赖关系:

代码语言:javascript
复制
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

代码语言:javascript
复制
<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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52203090

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档