1

没有 Phoenix 核心,spring boot 可以正确启动 tomcat。

问题:添加 compile('org.apache.phoenix:phoenix-core:4.7.0-HBase-1.1')dependencies我的部分build.gradle Tomcat无法启动

dependencies {
    compile('org.apache.phoenix:phoenix-core:4.7.0-HBase-1.1')
    compile("org.springframework.data:spring-data-commons")
    compile("org.springframework.boot:spring-boot-starter-jdbc:1.3.2.RELEASE")
    compile('org.springframework.boot:spring-boot-starter-web:1.3.2.RELEASE')
    compile("org.springframework:spring-test:4.2.4.RELEASE")
}

除了以下例外,

org.apache.catalina.core.ContainerBase startInternal
SEVERE: A child container failed during start
java.util.concurrent.ExecutionException: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/phoenix]]
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1123)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:816)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Tomcat].StandardHost[localhost].StandardContext[/phoenix]]
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:154)
    ... 6 more
Caused by: java.lang.NoSuchMethodError: javax.servlet.ServletContext.addServlet(Ljava/lang/String;Ljavax/servlet/Servlet;)Ljavax/servlet/ServletRegistration$Dynamic;
    at org.springframework.boot.context.embedded.ServletRegistrationBean.onStartup(ServletRegistrationBean.java:190)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.selfInitialize(EmbeddedWebApplicationContext.java:225)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.access$000(EmbeddedWebApplicationContext.java:85)
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext$1.onStartup(EmbeddedWebApplicationContext.java:209)
    at org.springframework.boot.contex2016-03-07 23:40:29.048  WARN 71400 --- [           main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
ded.tomcat.TomcatStarter.onStartup(TomcatStarter.java:55)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5513)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    ... 6 more
4

1 回答 1

1

添加到依赖项的以下行有助于解决该问题。

providedCompile "javax.servlet:javax.servlet-api:3.0.1"

dependencies {
    providedCompile "javax.servlet:javax.servlet-api:3.0.1"
    compile('org.apache.phoenix:phoenix-core:4.7.0-HBase-1.1')
    compile("org.springframework.data:spring-data-commons")
    compile("org.springframework.boot:spring-boot-starter-jdbc:1.3.2.RELEASE")
    compile('org.springframework.boot:spring-boot-starter-web:1.3.2.RELEASE')
    compile("org.springframework:spring-test:4.2.4.RELEASE")
}
于 2016-03-08T17:41:46.900 回答