Jetty加载参数的优先级:
- 命令行。
$JETTY_BASE
下的文件。- 使用
--include-jetty-dir
指定的目录下的文件。 $JETTY_HOME
下的文件。
查看当前的配置参数,执行如下命令:
java -jar $JETTY_HOME/start.jar --list-config
命令的输出如下:
Enabled Modules:
----------------1) resources transitive provider of resources for logging-jetty2) logging/slf4j transitive provider of logging/slf4j for logging-jettydynamic dependency of logging-jetty3) logging-jetty transitive provider of logging for threadpooltransitive provider of logging for bytebufferpooltransitive provider of logging for server4) bytebufferpool transitive provider of bytebufferpool for serverini template available with --add-modules=bytebufferpool5) threadpool transitive provider of threadpool for serverini template available with --add-modules=threadpool6) server ${jetty.base}/start.d/server.ini7) http ${jetty.base}/start.d/http.iniJVM Version & Properties:
-------------------------java.home = /home/jackie/software/jdk-21.0.2java.vm.vendor = Oracle Corporationjava.vm.version = 21.0.2+13-LTS-58java.vm.name = Java HotSpot(TM) 64-Bit Server VMjava.vm.info = mixed mode, sharingjava.runtime.name = Java(TM) SE Runtime Environmentjava.runtime.version = 21.0.2+13-LTS-58java.io.tmpdir = /tmpuser.dir = /home/jackie/workspace/jetty_runuser.language = enuser.country = USJetty Version & Properties:
---------------------------jetty.version = 12.0.6jetty.tag.version = jetty-12.0.6jetty.build = 78ab6e6ba163f89cdd97f2ae0283fbb5e371cfafjetty.home = /home/jackie/software/jetty-home-12.0.6jetty.base = /home/jackie/workspace/jetty_runConfig Search Order:
--------------------<command-line>${jetty.base} -> /home/jackie/workspace/jetty_run${jetty.home} -> /home/jackie/software/jetty-home-12.0.6System Properties:
------------------(no system properties specified)Properties: Jetty
-----------------java.version = 21.0.2java.version.major = 21java.version.micro = 2java.version.minor = 0java.version.platform = 21jetty.base = /home/jackie/workspace/jetty_runjetty.base.uri = file:///home/jackie/workspace/jetty_runjetty.home = /home/jackie/software/jetty-home-12.0.6jetty.home.uri = file:///home/jackie/software/jetty-home-12.0.6jetty.webapp.addServerClasses = org.eclipse.jetty.logging.,${jetty.home.uri}/lib/logging/,org.slf4j.runtime.feature.alpn = trueslf4j.version = 2.0.9Classpath: Jetty
----------------
Version Information on 8 entries in the classpath.
Note: order presented here is how they would appear on the classpath.changes to the --module=name command line options will be reflected here.0: (dir) | ${jetty.base}/resources1: 2.0.9 | ${jetty.home}/lib/logging/slf4j-api-2.0.9.jar2: 12.0.6 | ${jetty.home}/lib/logging/jetty-slf4j-impl-12.0.6.jar3: 12.0.6 | ${jetty.home}/lib/jetty-http-12.0.6.jar4: 12.0.6 | ${jetty.home}/lib/jetty-server-12.0.6.jar5: 12.0.6 | ${jetty.home}/lib/jetty-xml-12.0.6.jar6: 12.0.6 | ${jetty.home}/lib/jetty-util-12.0.6.jar7: 12.0.6 | ${jetty.home}/lib/jetty-io-12.0.6.jarActive XMLs: Jetty
------------------${jetty.home}/etc/jetty-bytebufferpool.xml${jetty.home}/etc/jetty-threadpool.xml${jetty.home}/etc/jetty.xml${jetty.home}/etc/jetty-http.xml
修改http
模块的配置文件$JETTY_BASE/start.d/http.ini
,指定jetty.http.port
为8081
。
查看配置文件中的参数,执行如下命令:
cat $JETTY_BASE/start.d/http.ini|grep "jetty.http.port"
命令的输出,如下:
jetty.http.port=8081
检查Jetty加载的参数,执行如下命令:
java -jar $JETTY_HOME/start.jar --list-config|grep "jetty.http.port"
命令的输出,如下:
jetty.http.port = 8081
在命令行指定指定jetty.http.port
为9091
,检查Jetty加载的参数,执行如下命令:
java -jar $JETTY_HOME/start.jar --list-config jetty.http.port=9091|grep "jetty.http.port"
命令的输出,如下:
jetty.http.port = 9091