如何设置jetty runnier应用程序的WebAppContext?

时间:2018-04-06 15:32:27

标签: java spring-boot jetty

我有一个使用spring boot的java web应用程序,它被打包为war文件 然后使用此命令使用jetty runner和xml配置文件部署war文件:

java -jar jetty-runner-9.2.9.v20150224.jar --config jetty.xml  application.war

jetty xml具有以下内容

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
    <Call name="addConnector">
        <Arg>
            <New class="org.eclipse.jetty.server.ServerConnector">
                <Arg name="server">
                    <Ref refid="Server"/>
                </Arg>
                <Set name="port">
                    <Property name="jetty.port" default="1312"/>
                </Set>
                <Set name="idleTimeout">3000000</Set>
            </New>
        </Arg>
    </Call>

    <Set name="stopAtShutdown">false</Set>
    <Set name="stopTimeout">5000000000</Set>
</Configure>

当我执行上面的命令时,我得到了以下输出

2018-04-06 10:07:01.953:INFO::main: Logging initialized @592ms
2018-04-06 10:07:01.997:INFO:oejr.Runner:main: Runner
2018-04-06 10:07:02.597:INFO:oejs.Server:main: jetty-9.2.9.v20150224
2018-04-06 10:07:18.437:INFO:/:main: Spring WebApplicationInitializers detected on classpath: [org.springframework.boot.autoconfigure.jersey.JerseyAutoConfiguration$JerseyWebApplicationInitializer@757942a1]
2018-04-06 10:07:49.516:INFO:/:main: Initializing Spring root WebApplicationContext
2018-04-06 10:07:55.120:INFO:/:main: Initializing Spring FrameworkServlet 'dispatcher'
DB created 1012 millis
2018-04-06 10:07:56.157:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext@12f40c25{/,file:/C:/Users/winuser/AppData/Local/Temp/jetty-0.0.0.0-1312-application.war-_-any-6813620977412039270.dir/webapp/,AVAILABLE}{file:/D:/webApps/xcerb/cerebro/app/application.war}
2018-04-06 10:07:56.160:WARN:oejsh.RequestLogHandler:main: !RequestLog
2018-04-06 10:07:56.203:INFO:oejs.ServerConnector:main: Started ServerConnector@323659f8{HTTP/1.1}{0.0.0.0:1312}
2018-04-06 10:07:56.205:INFO:oejs.Server:main: Started @54855ms

我想知道的是如何指定码头解压战的位置

file:/C:/Users/winuser/AppData/Local/Temp/jetty-0.0.0.0-1312-application.war-_-any-6813620977412039270.dir/webapp/

这个问题在Linux上,几天后操作系统删除了临时目录的内容而应用程序失败了

我已经查看jetty reference guidehere,但我看不到可用于更改位置的参数。

可以在jetty runner上覆盖这样的路径吗?

1 个答案:

答案 0 :(得分:1)

感谢Joakim Erdfelt,他只是提出了我需要的线索

只需要将-Djava.io.tmpdir=./scratch添加到命令

java -Djava.io.tmpdir=./scratch -jar jetty-runner-9.2.9.v20150224.jar --config jetty.xml  application.war

除此之外,如果需要,也可以指定-Djetty.home=dir,之后战争在另一个地方解压缩

file:/D:/webApps/xcerb/cerebro/scratch/jetty-0.0.0.0-1312-application.war-_-any-3819067265538641392.dir/webapp/