Jetty使用入门
社区当前推荐开发者使用Jetty 12.X版本。
依据End of Community Support for Jetty 9.x - June 2022,社区对Jetty 9.x的支持,已在2022年6月1日停止。
依据End of Community Support for Jetty 10 / Jetty 11 - January 2024,社区对Jetty 10.X、Jetty 11.X的支持,已在2024年1月停止。
官方资料
- jetty
- 官方文档主页
- jetty-9 The Definitive Reference
- jetty-12 Operations Guide
- jetty-12 Programming Guide
- jetty-11 Operations Guide
- jetty-11 Programming Guide
- jetty-10 Operations Guide
- jetty-10 Programming Guide
- jetty.project
参考资料
- ubuntu 安装jdk21开发环境
使用入门
安装JDK
使用JDK21,安装过程的命令如下:
cd ~/software
mkdir testwget https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.tar.gz
tar vxfz jdk-21_linux-x64_bin.tar.gz -C test
mv test/jdk-21.0.2 .
ln -s jdk-21.0.2 jdk21rm -rf testexport JAVA_HOME=~/software/jdk21
export PATH=$JAVA_HOME/bin:$PATH
查看版本,命令如下:
java --version
输出样例,如下:
java 21.0.2 2024-01-16 LTS
Java(TM) SE Runtime Environment (build 21.0.2+13-LTS-58)
Java HotSpot(TM) 64-Bit Server VM (build 21.0.2+13-LTS-58, mixed mode, sharing)
查看Jetty的版本
执行如下命令:
java -jar $JETTY_HOME/start.jar --version
命令的输出,如下:
Classpath: 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.jar
创建Jetty的环境变量
export JETTY_BASE=~/workspace/jetty_run
mkdir -p $JETTY_BASEexport JETTY_HOME=~/software/jetty-home-12.0.6
mkdir -p $JETTY_HOME
JETTY_HOME
指向jetty
软件包解压的路径。
JETTY_BASE
指向应用的路径。
列出指定模块
比如指定列出connector
的模块,命令样例如下:
java -jar $JETTY_HOME/start.jar --list-modules=connector
输出样例
Modules [connector]:
====================connector modules:
------------------acceptratelimit - Enables a server-wide accept rate limit.connectionlimit - Enables a server-wide connection limit.http - Enables a clear-text HTTP connector.http-forwarded - Enables processing of the "Forwarded" HTTP header (and its predecessors "X-Forwarded-*" HTTP headers).http2 - Enables the support for the secure HTTP/2 protocol.http2c - Enables the support for the clear-text HTTP/2 protocol.http3 - Enables experimental support for the HTTP/3 protocol.https - Adds HTTPS protocol support to the TLS(SSL) Connector.inetaccess - Enables the InetAccessHandler.
proxy-protocol-ssl - Enables the Proxy Protocol on the TLS(SSL) Connector.ssl-reload - Enables the KeyStore to be reloaded when the KeyStore file changes.unixdomain-http - Enables support for clear-text HTTP/1.1 over Java 16 Unix-Domain server sockets.
列出全部模块
命令样例如下:
java -jar $JETTY_HOME/start.jar --list-modules=*
命令的输出如下:
Modules [*]:
============acceptratelimit - Enables a server-wide accept rate limit.alpn-java - Provides the ALPN implementation based on the Java APIs.bytebufferpool - Configures the ByteBufferPool used by ServerConnectors.bytebufferpool-quadratic - Configures the ByteBufferPool used by ServerConnectors.client - Adds the Jetty HTTP client to the server classpath.connectionlimit - Enables a server-wide connection limit.conscrypt - Installs the Conscrypt JSSE provider.console-capture - Redirects the JVM console stderr and stdout to a rolling log file.core-demos - A meta module to enable all core demo modules.core-deploy - Enables application based on core handlers deployed from the $JETTY_BASE/webapps/ directory.cross-origin - Enables CrossOriginHandler to support the CORS protocol and protect from cross-site request forgery (CSRF) attacks.debug - Enables the DebugListener.decorate - Jetty setup to support Decoration of Listeners, Filters and Servlets within a deployed webapp.delay-until-content - Applies DelayedHandler to entire server.demo-handler - Demo Handlerdemo-jaas - Setup for jaas demos.demo-moved-context - Demonstrate a Moved Context Handler setup in XMLdemo-realm - Configure a demo authentication realm.demo-root - Demo root context.demos - A meta module to enable all demo modules.deploy - This module enables web application deployment from the `$JETTY_BASE/webapps` directory.ee10-annotations - Enables Annotation scanning for deployed web applications.ee10-apache-jsp - Enables use of the apache implementation of JSP.ee10-cdi - Provides integration of CDI within webapp to Jetty container object lifecycles.ee10-cdi-decorate - Configures Jetty to use the "CdiDecoratingListener" as the default CDI mode.ee10-cdi-spi - Configures Jetty to use the "CdiSpiDecorator" as the default CDI mode.ee10-demo-async-rest - Demo Async Rest webappee10-demo-jaas - Demo EE10 JAAS webappee10-demo-jetty - Demo Jetty Webappee10-demo-jndi - Demo JNDI Resources Webappee10-demo-jsp - Demo Simple JSP Webappee10-demo-mock-resources - Download and install some Demo Mock Resourcesee10-demo-proxy - Demo Proxy Webappee10-demo-rewrite - Demonstrate the rewrite module.ee10-demo-simple - Demo Simple Webappee10-demo-spec - Download and deploy the Test Spec webapp demo.ee10-demos - A meta module to enable all EE10 demo modules.ee10-deploy - This module enables webapp deployment from the `$JETTY_BASE/webapps` directory.ee10-fcgi-proxy - Enables support for EE10 FastCGI proxying.ee10-glassfish-jstl - Enables the glassfish version of JSTL for all webapps.ee10-jaspi - Enables JASPI authentication for deployed web applications.
ee10-jaspi-default-auth-config-factory - Provides a DefaultAuthConfigFactory for jaspiee10-jaspi-demo - Enables JASPI basic authentication the /test context path.ee10-jndi - Adds the Jetty EE10 JNDI reference factoriesee10-jsp - Enables JSP for all web applications deployed on the server.ee10-jstl - Enables JSTL for all web applications deployed on the server.ee10-openid - Adds openid security for EE10.ee10-plus - Enables Servlet resource injection.ee10-proxy - Enables the Jetty Proxy service.ee10-quickstart - Enables the Jetty Quickstart module for rapid deployment of preconfigured web applications.ee10-security - Adds servlet standard security handling to the classpath.ee10-servlet - Enables standard Servlet handling.ee10-servlets - Adds Jetty EE10 utility servlets and filters available to a webapp.ee10-webapp - This module enables deployment of Java Servlet web applications.ee10-websocket-jakarta - Enable jakarta.websocket APIs for deployed web applications.ee10-websocket-jetty - Enable the Jetty WebSocket API support for deployed web applications.ee10-websocket-jetty-client-webapp - Expose the Jetty WebSocket Client classes to deployed web applications.ee8-annotations - Enables Annotation scanning for deployed web applications.ee8-apache-jsp - Enables use of the apache implementation of JSP.ee8-demo-async-rest - Demo Async Rest webappee8-demo-jaas - Demo EE8 JAAS webappee8-demo-jetty - Demo Jetty Webappee8-demo-jndi - Demo JNDI Resources Webappee8-demo-jsp - Demo Simple JSP Webappee8-demo-mock-resources - Download and install some Demo Mock Resourcesee8-demo-moved-context - Demonstrate a Moved Context Handler.ee8-demo-proxy - Demo Proxy Webappee8-demo-rewrite - Demonstrate the rewrite module.ee8-demo-simple - Demo EE8 Simple Webappee8-demo-spec - Download and deploy the Test Spec webapp demo.ee8-demos - A meta module to enable all EE8 demo modules.ee8-deploy - This module enables webapp deployment from the `$JETTY_BASE/webapps` directory.ee8-glassfish-jstl - Enables the glassfish version of JSTL for all webapps.ee8-jndi - Adds the Jetty EE8 JNDI reference factoriesee8-jsp - Enables JSP for all web applications deployed on the server.ee8-jstl - Enables JSTL for all web applications deployed on the server.ee8-openid - Adds OpenId Connect authentication to the server.ee8-plus - Enables Servlet 3.1 resource injection.ee8-proxy - Enables the Jetty Proxy service.ee8-quickstart - Enables the Jetty Quickstart module for rapid deployment of preconfigured web applications.ee8-security - Adds servlet standard security handling to the classpath.ee8-servlet - Enables standard Servlet handling.ee8-servlets - Adds Jetty EE8 utility servlets and filters available to a webapp.ee8-webapp - Adds support for servlet specification web applications to the server classpath.ee8-websocket-javax - Enable javax.websocket APIs for deployed web applications.ee8-websocket-jetty - Enable the Jetty WebSocket API support for deployed web applications.ee8-websocket-jetty-client - Expose the Jetty WebSocket Client classes to deployed web applications.ee8-websocket-jetty-client-webapp - Expose the Jetty WebSocket Client classes to deployed web applications.ee9-annotations - Enables Annotation scanning for deployed web applications.ee9-apache-jsp - Enables use of the apache implementation of JSP.ee9-cdi - Provides integration of CDI within webapp to Jetty container object lifecycles.ee9-cdi-decorate - Configures Jetty to use the "CdiDecoratingListener" as the default CDI mode.ee9-cdi-spi - Configures Jetty to use the "CdiSpiDecorator" as the default CDI mode.ee9-demo-async-rest - Demo Async Rest webappee9-demo-jaas - Demo EE9 JAAS webappee9-demo-jetty - Demo Jetty Webappee9-demo-jndi - Demo JNDI Resources Webappee9-demo-jsp - Demo Simple JSP Webappee9-demo-mock-resources - Download and install some Demo Mock Resourcesee9-demo-proxy - Demo Proxy Webappee9-demo-rewrite - Demonstrate the rewrite module.ee9-demo-simple - Demo EE9 Simple Webappee9-demo-spec - Download and deploy the Test Spec webapp demo.ee9-demos - A meta module to enable all EE9 demo modules.ee9-deploy - This module enables webapp deployment from the `$JETTY_BASE/webapps` directory.ee9-fcgi-proxy - Enables support for EE9 FastCGI proxying.ee9-glassfish-jstl - Enables the glassfish version of JSTL for all webapps.ee9-jaspi - Enables JASPI authentication for deployed web applications.ee9-jaspi-default-auth-config-factory - Provides a DefaultAuthConfigFactory for jaspiee9-jaspi-demo - Enables JASPI basic authentication the /test context path.ee9-jndi - Adds the Jetty EE9 JNDI reference factoriesee9-jsp - Enables JSP for all web applications deployed on the server.ee9-jstl - Enables JSTL for all web applications deployed on the server.ee9-openid - Adds OpenId Connect authentication to the server.ee9-plus - Enables Servlet 3.1 resource injection.ee9-proxy - Enables the Jetty Proxy service.ee9-quickstart - Enables the Jetty Quickstart module for rapid deployment of preconfigured web applications.ee9-security - Adds servlet standard security handling to the classpath.ee9-servlet - Enables standard Servlet handling.ee9-servlets - Adds Jetty EE9 utility servlets and filters available to a webapp.ee9-webapp - Adds support for servlet specification web applications to the server classpath.ee9-websocket-jakarta - Enable jakarta.websocket APIs for deployed web applications.ee9-websocket-jetty - Enable the Jetty WebSocket API support for deployed web applications.ee9-websocket-jetty-client-webapp - Expose the Jetty WebSocket Client classes to deployed web applications.ext - Adds the jar file from $JETTY_HOME/lib/ext and $JETTY_BASE/lib/ext to the server classpath.fcgi - Enables support for the FastCGI protocol.fcgi-proxy - Enables support for HTTP to FastCGI proxying.flight-recorder - Enables Java Mission Control's Flight Recorder for low overhead profiling.gcloud - Controls GCloud API classpath.gcloud-datastore - Enables GCloud Datastore API and implementation.global-webapp-common - Enables Deployer to apply common configuration to all webapp deployments.graceful - Enables Graceful processing of requestsgzip - Enables GzipHandler for dynamic gzip compression for the entire server.home-base-warning - Generates a warning that server has been run from $JETTY_HOME rather than from a $JETTY_BASE.http - Enables a clear-text HTTP connector.http-forwarded - Enables processing of the "Forwarded" HTTP header (and its predecessors "X-Forwarded-*" HTTP headers).http2 - Enables the support for the secure HTTP/2 protocol.http2c - Enables the support for the clear-text HTTP/2 protocol.http3 - Enables experimental support for the HTTP/3 protocol.https - Adds HTTPS protocol support to the TLS(SSL) Connector.inetaccess - Enables the InetAccessHandler.infinispan-embedded - Setup infinispan embedded without querying.infinispan-embedded-query - Enables querying with the Infinispan session cache.infinispan-remote - Default setup for the remote infinispan cache without queries.infinispan-remote-query - Enables querying with a remote Infinispan cache.jaas - Enables JAAS for deployed web applications.jdbc - Enables the java.sql JPMS module.jmx - This module enables local Java Management Extension (JMX) support for Jetty components.jmx-remote - Enables clear-text remote RMI access to platform MBeans.jmx-remote-auth - Enables authentication and authorization for remote clientsjmx-remote-ssl - Enables secure remote RMI access to platform MBeans.jna - Provides Java Native Access (JNA) support.jndi - Adds the Jetty JNDI implementation to the classpath.jvm - Creates an ini template for setting JVM arguments (eg -Xmx ).logging-jcl-capture - Captures jakarta-commons-logging events and bridges them to SLF4J.logging-jetty - Base configuration for the jetty logging mechanism.logging-jul - Configures jetty logging to use Java Util Logging (jul).logging-jul-capture - Captures java.util.logging events and bridges them to slf4j.logging-log4j1 - Configures Jetty logging to use Log4j.logging-log4j1-capture - Captures Apache log4j events and bridges them to SLF4J.logging-log4j2 - Configures Jetty logging to use log4j version 2.logging-logback - Configures Jetty logging to use Logback Logging.logging-noop - Configures Jetty logging to use SLF4J No-Op Implementation.logging/slf4j - Configures logging to use SLF4J.lowresources - Enables a low resource monitor on the server.openid - Adds OpenId Connect authentication to the server.pid - Creates the PID file for the Jetty processplus - Adds the Jetty Plus JNDI support to the classpath.proxy - Enables support for HTTP proxying.proxy-protocol - Enables PROXY Protocol (https://www.haproxy.org/download/2.1/doc/proxy-protocol.txt)proxy-protocol-ssl - Enables the Proxy Protocol on the TLS(SSL) Connector.quiche - Provides Native binary builds for the Quiche library.requestlog - Logs requests using CustomRequestLog and AsyncRequestLogWriter.resources - This module adds the `$JETTY_BASE/resources` directory to the server's classpath.rewrite - Enables the jetty-rewrite handler.rewrite-compactpath - Add a rule to the rewrite module to compact paths.rewrite-customizer - Enables a rewrite Rules container as a request customizer.secure-redirect - Enable SecuredRedirectHandler to redirect all http requests to https on the secure port configured in the server.ini file.security - Adds core security handling to the classpath.server - Enables and configures the Jetty server.session-cache-hash - Enable first level session cache.session-cache-null - A SessionCache that does not actually cache sessions.session-store-cache - Enables caching of SessionData in front of a SessionDataStore.session-store-file - Enables session persistent storage in files.session-store-gcloud - Enables GCloudDatastore session management.session-store-hazelcast-embedded - Enables session data store in an embedded Hazelcast Map.session-store-hazelcast-remote - Enables session data store in a remote Hazelcast Map.session-store-infinispan-embedded - Enables session data store in a local Infinispan cache.session-store-infinispan-remote - Enables session data store in a remote Infinispan cache.session-store-jdbc - Enables JDBC persistent/distributed session storage.session-store-mongo - Enables NoSql session management with a MongoDB driver.sessions - Enables session management.setuid - Enables the UNIX setUID configuration.ssl-reload - Enables the KeyStore to be reloaded when the KeyStore file changes.state - Creates and updates state file used by jetty.shstatistics - Enables statistics collection for the server.stop - This module causes Jetty to stop immediately after starting.test-keystore - Test keystore with self-signed SSL Certificate.threadlimit - Applies ThreadLimitHandler to entire server, to limit the threads per IP address for DOS protection.threadpool - Enables and configures the Server ThreadPool.threadpool-virtual - Enables and configures the Server ThreadPool with support for virtual threads in Java 21 or later.threadpool-virtual-preview - Enables and configures the Server ThreadPool with support for virtual threads in Java 19 and Java 20.unixdomain-http - Enables support for clear-text HTTP/1.1 over Java 16 Unix-Domain server sockets.websocket-jetty - Enables the Jetty WebSocket API support for deployed web applications.websocket-jetty-client - Expose the Jetty WebSocket Client classes to deployed web applications.well-known - Serve static files from a directory for the "/.well-known" context path.work - Creates the $JETTY_BASE/work directory as a persistent temp directory.Enabled Modules:
----------------0) resources transitive provider of resources for logging-jetty1) logging/slf4j transitive provider of logging/slf4j for logging-jettydynamic dependency of logging-jetty2) logging-jetty transitive provider of logging for threadpooltransitive provider of logging for bytebufferpooltransitive provider of logging for server3) bytebufferpool transitive provider of bytebufferpool for serverini template available with --add-modules=bytebufferpool4) threadpool transitive provider of threadpool for serverini template available with --add-modules=threadpool5) server ${jetty.base}/start.d/server.ini6) http ${jetty.base}/start.d/http.ini7) ssl ${jetty.base}/start.d/ssl.ini8) https ${jetty.base}/start.d/https.ini
启用模块
以http
为例,执行如下命令:
java -jar $JETTY_HOME/start.jar --add-modules=http
命令的输出,如下:
INFO : mkdir ${jetty.base}/start.d
INFO : server transitively enabled, ini template available with --add-modules=server
INFO : logging-jetty transitively enabled
INFO : http initialized in ${jetty.base}/start.d/http.ini
INFO : resources transitively enabled
INFO : threadpool transitively enabled, ini template available with --add-modules=threadpool
INFO : logging/slf4j dynamic dependency of logging-jetty
INFO : bytebufferpool transitively enabled, ini template available with --add-modules=bytebufferpool
INFO : mkdir ${jetty.base}/resources
INFO : copy ${jetty.home}/modules/logging/jetty/resources/jetty-logging.properties to ${jetty.base}/resources/jetty-logging.properties
INFO : Base directory was modified
检查$JETTY_BASE
目录下的文件,执行如下命令:
tree $JETTY_BASE
命令的输出,如下:
.
├── resources
│ └── jetty-logging.properties
└── start.d└── http.ini2 directories, 2 files
查看帮助
命令样例,如下:
java -jar $JETTY_HOME/start.jar --help
命令的输出,如下:
Usage:$ java -jar $JETTY_HOME/start.jar [command] [options...]Commands can be of two types: report commands or configuration commands.
Commands execute and then exit the JVM.
Options can be specified with or without commands.
When no command is specified, Jetty is started with the given options.Report Commands:
------------------helpPrints this help / usage information.--versionPrints the version information for Jetty anddependent jars, then exits.--list-classpathPrints the class-path (or module-path) information thatwill be used to start Jetty.--list-configLists the resolved configuration that will be used tostart Jetty.Output includes:o Enabled Jetty moduleso Java environmento Jetty environmento Config file search ordero JVM argumentso System propertieso Propertieso Java class-path or module-patho XML configuration files--list-modulesLists the modules defined in ${jetty.base}/modules/*.modand then in ${jetty.home}/modules/*.mod.--list-modules=<tag>(,<tag>)*Lists the modules by tag. Use '*' for all tags.Prefix a tag with '-' to exclude the tag.The special tag "internal" is always excluded unless it isexplicitly included.--list-all-modulesLists all modules.--show-modules=<module>(,<module>)*Shows the detail of the listed modules, includingdependencies, tags, libraries and XMLs.--stopSends a stop signal to the running Jetty instance.The running Jetty instance must have been started with astop.port=<port> property and the --stop command mustbe executed with the same property.--dry-runPrints the command line that start.jar generates,in a format usable by a POSIX compliant shell, then exits.This may be used to generate command lines into scripts:$ java -jar start.jar --dry-run > jetty.sh--dry-run=<part>(,<part>)*Prints specific parts of the command line in a format usable bya POSIX compliant shell. The parts are:o "java" - the JVM to runo "opts" - the JVM options (e.g. -D, -X and -XX flags)o "path" - the JVM class-path and/or the JPMS module-patho "main" - the main class to runo "args" - the arguments passed to the main classo "envs" - the generated XML files to create the environmentsConfigure Commands:
---------------------add-modules=<moduleName>(,<moduleName>)*Adds the given modules to the list of modules enabled atwhen Jetty starts.Transitive dependencies are followed and dependentmodules may also explicitly added.Modules are added by creating an *.ini file in the${jetty.base}/start.d/ directory.The *.ini file contains the --module option that enablesthe module, and any other option defined in the module's[ini-template] section.If the *.ini file specifies properties, these may beoverridden by specifying the same properties on thecommand line.If a module is transitively enabled, its *.ini file willnot be generated.To generate the *.ini file, the module must be explicitlylisted in the --add-modules=... command.This option replaces the deprecated --add-to-start and--add-to-startd commands.--create-start-dCreates a ${jetty.base}/start.d directory.If the ${jetty.base}/start.ini file exists, then it ismoved into the ${jetty.base}/start.d/ directory.Using a ${jetty.base}/start.d/ directory is the default andthis option is only needed to either force the creation ofthe ${jetty.base}/start.d/ directory, or to move a${jetty.base}/start.ini file to ${jetty.base}/start.d/.--create-start-iniCreates a ${jetty.base}/start.ini file.If a ${jetty.base}/start.d/ directory exists, then allthe contained *.ini files are concatenated into the${jetty.base}/start.ini file.--update-iniScans all the ${jetty.base}/start.d/*.ini files and updatesany property with values specified on the command line.For example:$ java -jar ${jetty.host}/start.jar --update-ini jetty.http.port=8888--create-filesCreates any missing files that are required by enabledmodules, as specified in their [files] section.This may download a file from the network if a HTTP URIis specified in the [files] section.--write-module-graph=<filename>Creates a graphviz *.dot file of the module graph as itis configured for the current ${jetty.base}.See https://graphviz.org/ for details on how to post-processthis file into the output best suited for your needs.Options:
----------modules=<moduleName>(,<moduleName>)*Enables a module for this execution.To enable a module for all future executions, use the--add-modules command.Note: this option is used in the ${jetty.base}/start.inifile or in ${jetty.base}/start.d/*.ini files created bythe --add-modules command.--libs=<classpath>Adds the specified class-path entries to the the serverclass-path (or module-path).--download=<http-uri>|<location>Downloads a file from the given HTTP URI, if it doesnot already exist at the given location.Note: the location is always relative to ${jetty.base}.You might need to escape the pipe "\|" to use it insome shell environments.--execExecutes the generated command line in a forked JVM(see the --dry-run command).This can be used when ${jetty.base}/start.d/*.ini filescontain -D, -X or -XX arguments, but creates an extraJVM process.--exec-properties=<filename>Assigns a fixed name to the file used to transferproperties to the sub process. This allows thegenerated properties file to be saved and reused.Without this option, a temporary file is used.--commands=<filename>Uses each line of the specified file as arguments on theJVM command line.--jpmsStarts Jetty in JPMS mode in a forked JVM (see also the--dry-run command).The library *.jar files are set on the forked JVM module-path(rather than the forked JVM class-path), while directoriesare set on the forked JVM class-path.The main class is specified with the JPMS option--module <moduleName>/<mainClassName>.--debugEnables debug output of the startup execution.Note: this does not setup debug logging for Jetty itself,only for the startup execution.If you want debug logging for Jetty, configure one of theavailable logging modules using the --add-modules command.--start-log-file=<filename>A filename, relative to ${jetty.base}, where all startupoutput will be sent. This is useful for capturing startupissues when the Jetty logging module has not yet starteddue to configuration errors.--allow-insecure-http-downloadsAllow the use of insecure `http://` scheme for content download.--approve-all-licensesApproves all license questions from modules that haveparticular license requirements.Useful for enabling modules from a script, so that itdoes not require user interaction.--skip-file-validation=<moduleName>(,<moduleName>)*Disables the creation of files as specified by the[files] section of the specified modules.Useful if a logging module specifies a *.propertiesconfig file, but you want to use that module with an*.xml config file instead.--include-jetty-dir=<path>Includes the specified directory as a configuration source.This directory behaves similarly to ${jetty.base} but sitsat a layer between ${jetty.home} and ${jetty.base}.Useful when you want to apply a common "corporate"configuration to all specific ${jetty.base} directorieswithout having to modify ${jetty.home}.jetty.home=<directory>Sets the ${jetty.home} directory.By default it is resolved from the start.jar file path.jetty.base=<directory>Sets the ${jetty.base} directory.By default it is resolved from the current directory path.stop.host=<string>Used with the --stop command.Specifies the host where the Jetty server to stop isrunning (defaults to 127.0.0.1).stop.port=<number>Used with the --stop command.Specifies the port to use to contact the Jetty serverto stop.stop.key=<alphanumeric>Used with the --stop command.The passphrase required to stop the Jetty server.stop.wait=<number>Used with the --stop command.The time, in seconds, to wait for confirmation that therunning Jetty server has stopped.If not specified, the stopper will not wait.maven.repo.uri=<url>The base URL to use to download Maven dependencies.Defaults to: https://repo1.maven.org/maven2/.<name>=<value>Specifies a property value that overrides the sameproperty defined in a ${jetty.base}/start.d/*.ini file,or in the [ini] section of a *.mod file.<name>=<value>Sets the property value unconditionally.<name>+=<value>Appends the given value to the existing value.<name>?=<value>Sets the property value only if it is not already set.-D<name>=<value>Specifies a system property, as well as a start property.Note: this is a program argument that is interpreted andadded to the existing JVM system properties.<xml-file>Specifies a Jetty XML file relative to ${jetty.base}.This file is in addition to the Jetty XML files resolvedfrom the [xml] sections of the enabled modules.
查看模块的信息
命令样例如下:
java -jar $JETTY_HOME/start.jar --show-modules=http
命令的输出,如下:
Module: http: Enables a clear-text HTTP connector.: By default clear-text HTTP/1.1 is enabled, and clear-text HTTP/2 may be added by enabling the "http2c" module.Tags: connector, httpDepend: serverXML: etc/jetty-http.xmlEnabled: ${jetty.base}/start.d/http.ini
查看Jetty的命令行选项
命令样例,如下:
java -jar $JETTY_HOME/start.jar --dry-run
命令的输出,如下:
/home/jackie/software/jdk-21.0.2/bin/java -Djava.io.tmpdir=/tmp -Djetty.home=/home/jackie/software/jetty-home-12.0.6 -Djetty.base=/home/jackie/workspace/jetty_run --class-path /home/jackie/workspace/jetty_run/resources:/home/jackie/software/jetty-home-12.0.6/lib/logging/slf4j-api-2.0.9.jar:/home/jackie/software/jetty-home-12.0.6/lib/logging/jetty-slf4j-impl-12.0.6.jar:/home/jackie/software/jetty-home-12.0.6/lib/jetty-http-12.0.6.jar:/home/jackie/software/jetty-home-12.0.6/lib/jetty-server-12.0.6.jar:/home/jackie/software/jetty-home-12.0.6/lib/jetty-xml-12.0.6.jar:/home/jackie/software/jetty-home-12.0.6/lib/jetty-util-12.0.6.jar:/home/jackie/software/jetty-home-12.0.6/lib/jetty-io-12.0.6.jar org.eclipse.jetty.xml.XmlConfiguration java.version=21.0.2 jetty.base=/home/jackie/workspace/jetty_run jetty.base.uri=file:///home/jackie/workspace/jetty_run jetty.home=/home/jackie/software/jetty-home-12.0.6 jetty.home.uri=file:///home/jackie/software/jetty-home-12.0.6 jetty.webapp.addServerClasses=org.eclipse.jetty.logging.,file:///home/jackie/software/jetty-home-12.0.6/lib/logging/,org.slf4j. runtime.feature.alpn=true slf4j.version=2.0.9 /home/jackie/software/jetty-home-12.0.6/etc/jetty-bytebufferpool.xml /home/jackie/software/jetty-home-12.0.6/etc/jetty-threadpool.xml /home/jackie/software/jetty-home-12.0.6/etc/jetty.xml /home/jackie/software/jetty-home-12.0.6/etc/jetty-http.xml /home/jackie/software/jetty-home-12.0.6/etc/jetty-ssl.xml /home/jackie/software/jetty-home-12.0.6/etc/jetty-ssl-context.xml /home/jackie/software/jetty-home-12.0.6/etc/jetty-https.xml