首页 文章

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

提问于
浏览
0

我有一个使用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

我想知道的是 how can I specify where jetty will unzip the war

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

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

我已经看过jetty reference guidehere但是我看不到可用于更改位置的参数 .

is it possible to overwrite such path on jetty runner?

1 回答

  • 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/
    

相关问题