如何将Spring Boot应用程序部署到Tomcat 6 Servlet 2.5 [英] How to deploy Spring Boot app to Tomcat 6 Servlet 2.5

查看:1609
本文介绍了如何将Spring Boot应用程序部署到Tomcat 6 Servlet 2.5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用弹簧启动创建了一个常见问题。它需要部署到tomcat 6服务器(servlet 2.5)。我需要配置当前的父java应用程序(war)web.xml将所有请求的url模式/ faq / *指向我的spring boot常见问题应用程序。我将FAQ.jar文件复制到父应用程序的lib文件夹中。但是我不知道如何在父应用程序的web.xml中配置/注册spring启动servlet和servlet映射。



使用spring boot legacy示例..我将spring启动应用程序放在父应用程序li​​b文件夹以及依赖项jar文件中。我将该代码块添加到父应用程序的web.xml中。

 < context-param> 
< param-name> contextConfigLocation< / param-name>
< param-value> faq.Application< / param-value>
< / context-param>

< listener>
< listener-class>
org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener
< / listener-class>
< / listener>

< filter>
< filter-name> metricFilter< / filter-name>
< filter-class> org.springframework.web.filter.DelegatingFilterProxy< / filter-class>
< / filter>

< filter-mapping>
< filter-name> metricFilter< / filter-name>
< url-pattern> / *< / url-pattern>
< / filter-mapping>

< servlet>
< servlet-name> SpringServlet< / servlet-name>
< servlet-class> org.springframework.web.servlet.DispatcherServlet< / servlet-class>
< init-param>
< param-name> contextAttribute< / param-name>
< param-value> org.springframework.web.context.WebApplicationContext.ROOT< / param-value>
< / init-param>
< load-on-startup> 1< / load-on-startup>
< / servlet>

< servlet-mapping>
< servlet-name> SpringServlet< / servlet-name>
< url-pattern> /< / url-pattern>
< / servlet-mapping>

但是当我启动Tomcat时,我收到以下错误。



2014年6月30日12:17:23 org.apache.catalina.core.StandardContext listenerStart
SEVERE:异常发送上下文初始化事件到监听器实例类org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener
java.lang.IllegalAccessError:尝试访问方法org.springframework.core.io.support.SpringFactoriesLoader.loadFactoryNames(Ljava / lang / Class; Ljava /朗/类加载器;)Ljava / util的/列表;从org.springframework.boot.SpringApplication
在org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:355)
在org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:346 )
在org.springframework.boot.SpringApplication.initialize(SpringApplication.java:222)
在org.springframework.boot.SpringApplication。(SpringApplication.java:198)
在org.springframework .boot.builder.SpringApplicationBuilder(SpringApplicationBuilder.java:83)
在org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener.initWebApplicationContext(SpringBootContextLoaderListener.java:48)
在org.springframework。 web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
在org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779)
在org.apache.catalina.core。 StandardContext.startInternal(StandardC ontext.java:5273)
在org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
在org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java: 897)
在org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:873)
在org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615)
在org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1095)
在org.apache.catalina.startup.HostConfig $ DeployDirectory.run(HostConfig.java:1617)
在java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:441)
在java.util.concurrent.FutureTask $ Sync.innerRun(FutureTask.java:303)
在java.util .concurrent.FutureTask.run(FutureTask.java:138)
在java.util.concurrent.ThreadPoolExecutor $ Worker.runTask(ThreadPoolExecutor.java:886)
在java.util.concurrent.ThreadPoolExecutor $ Worker .run(ThreadPoolExecutor.java:908)
在java.lang.Thread.run(Thread.j ava:619)
2014年6月30日12:17:23 AM org.apache.catalina.core.StandardContext startInternal
SEVERE:Error listenerStart



KevyKev

解决方案

Spring Boot不支持Servlet 2.5正式使用,但它并没有太多的工作。您可能会发现这有用: https://github.com/scratches/spring-boot-legacy。示例: https://github.com/scratches/spring-boot-sample-gae


I created a FAQ using spring boot. it needs to be deployed to a tomcat 6 server (servlet 2.5). I need to configure the current parent java app(war) web.xml to point all request to url pattern "/faq/*" for example, to my spring boot FAQ app. I've copied the FAQ.jar file into the lib folder of the parent app. But I'm not sure how to configure/register the spring boot servlet and servlet mapping within the web.xml of the parent application.

Using the spring boot legacy sample.. I placed my spring boot app in the parent app lib folder along with the dependency jar files. I added this code block to the web.xml of the parent app.

 <context-param>
     <param-name>contextConfigLocation</param-name>
     <param-value>faq.Application</param-value>
 </context-param>

  <listener>
      <listener-class>
          org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener
      </listener-class>
  </listener>

  <filter>
      <filter-name>metricFilter</filter-name>
      <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
  </filter>

<filter-mapping>
    <filter-name>metricFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<servlet>
    <servlet-name>SpringServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextAttribute</param-name>
        <param-value>org.springframework.web.context.WebApplicationContext.ROOT</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>SpringServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

But when I start up Tomcat, I get the following error.

Jun 30, 2014 12:17:23 AM org.apache.catalina.core.StandardContext listenerStart SEVERE: Exception sending context initialized event to listener instance of class org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener java.lang.IllegalAccessError: tried to access method org.springframework.core.io.support.SpringFactoriesLoader.loadFactoryNames(Ljava/lang/Class;Ljava/lang/ClassLoader;)Ljava/util/List; from class org.springframework.boot.SpringApplication at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:355) at org.springframework.boot.SpringApplication.getSpringFactoriesInstances(SpringApplication.java:346) at org.springframework.boot.SpringApplication.initialize(SpringApplication.java:222) at org.springframework.boot.SpringApplication.(SpringApplication.java:198) at org.springframework.boot.builder.SpringApplicationBuilder.(SpringApplicationBuilder.java:83) at org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener.initWebApplicationContext(SpringBootContextLoaderListener.java:48) at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47) at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4779) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5273) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:897) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:873) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:615) at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1095) at org.apache.catalina.startup.HostConfig$DeployDirectory.run(HostConfig.java:1617) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) at java.util.concurrent.FutureTask.run(FutureTask.java:138) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) at java.lang.Thread.run(Thread.java:619) Jun 30, 2014 12:17:23 AM org.apache.catalina.core.StandardContext startInternal SEVERE: Error listenerStart

KevyKev

解决方案

Spring Boot doesn't support Servlet 2.5 officially, but it doesn't take a lot to make it work. You might find this useful: https://github.com/scratches/spring-boot-legacy. Sample here: https://github.com/scratches/spring-boot-sample-gae.

这篇关于如何将Spring Boot应用程序部署到Tomcat 6 Servlet 2.5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆