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月停止。
官方资料
参考资料
使用入门
安装JDK
使用JDK21,安装过程的命令如下:
cd ~/software
mkdir test
wget 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 jdk21
rm -rf test
export 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}/resources
1: 2.0.9 | ${jetty.home}/lib/logging/slf4j-api-2.0.9.jar
2: 12.0.6 | ${jetty.home}/lib/logging/jetty-slf4j-impl-12.0.6.jar
3: 12.0.6 | ${jetty.home}/lib/jetty-http-12.0.6.jar
4: 12.0.6 | ${jetty.home}/lib/jetty-server-12.0.6.jar
5: 12.0.6 | ${jetty.home}/lib/jetty-xml-12.0.6.jar
6: 12.0.6 | ${jetty.home}/lib/jetty-util-12.0.6.jar
7: 12.0.6 | ${jetty.home}/lib/jetty-io-12.0.6.jar
创建Jetty的环境变量
export JETTY_BASE=~/workspace/jetty_run
mkdir -p $JETTY_BASE
export 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 Handler
demo-jaas - Setup for jaas demos.
demo-moved-context - Demonstrate a Moved Context Handler setup in XML
demo-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 webapp
ee10-demo-jaas - Demo EE10 JAAS webapp
ee10-demo-jetty - Demo Jetty Webapp
ee10-demo-jndi - Demo JNDI Resources Webapp
ee10-demo-jsp - Demo Simple JSP Webapp
ee10-demo-mock-resources - Download and install some Demo Mock Resources
ee10-demo-proxy - Demo Proxy Webapp
ee10-demo-rewrite - Demonstrate the rewrite module.
ee10-demo-simple - Demo Simple Webapp
ee10-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 jaspi
ee10-jaspi-demo - Enables JASPI basic authentication the /test context path.
ee10-jndi - Adds the Jetty EE10 JNDI reference factories
ee10-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 webapp
ee8-demo-jaas - Demo EE8 JAAS webapp
ee8-demo-jetty - Demo Jetty Webapp
ee8-demo-jndi - Demo JNDI Resources Webapp
ee8-demo-jsp - Demo Simple JSP Webapp
ee8-demo-mock-resources - Download and install some Demo Mock Resources
ee8-demo-moved-context - Demonstrate a Moved Context Handler.
ee8-demo-proxy - Demo Proxy Webapp
ee8-demo-rewrite - Demonstrate the rewrite module.
ee8-demo-simple - Demo EE8 Simple Webapp
ee8-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 factories
ee8-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 webapp
ee9-demo-jaas - Demo EE9 JAAS webapp
ee9-demo-jetty - Demo Jetty Webapp
ee9-demo-jndi - Demo JNDI Resources Webapp
ee9-demo-jsp - Demo Simple JSP Webapp
ee9-demo-mock-resources - Download and install some Demo Mock Resources
ee9-demo-proxy - Demo Proxy Webapp
ee9-demo-rewrite - Demonstrate the rewrite module.
ee9-demo-simple - Demo EE9 Simple Webapp
ee9-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 jaspi
ee9-jaspi-demo - Enables JASPI basic authentication the /test context path.
ee9-jndi - Adds the Jetty EE9 JNDI reference factories
ee9-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 requests
gzip - 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 clients
jmx-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 process
plus - 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.sh
statistics - 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-jetty
1) logging/slf4j transitive provider of logging/slf4j for logging-jetty
dynamic dependency of logging-jetty
2) logging-jetty transitive provider of logging for threadpool
transitive provider of logging for bytebufferpool
transitive provider of logging for server
3) bytebufferpool transitive provider of bytebufferpool for server
ini template available with --add-modules=bytebufferpool
4) threadpool transitive provider of threadpool for server
ini template available with --add-modules=threadpool
5) server ${jetty.base}/start.d/server.ini
6) http ${jetty.base}/start.d/http.ini
7) ssl ${jetty.base}/start.d/ssl.ini
8) 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.ini
2 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:
----------------
--help
Prints this help / usage information.
--version
Prints the version information for Jetty and
dependent jars, then exits.
--list-classpath
Prints the class-path (or module-path) information that
will be used to start Jetty.
--list-config
Lists the resolved configuration that will be used to
start Jetty.
Output includes:
o Enabled Jetty modules
o Java environment
o Jetty environment
o Config file search order
o JVM arguments
o System properties
o Properties
o Java class-path or module-path
o XML configuration files
--list-modules
Lists the modules defined in ${jetty.base}/modules/*.mod
and 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 is
explicitly included.
--list-all-modules
Lists all modules.
--show-modules=<module>(,<module>)*
Shows the detail of the listed modules, including
dependencies, tags, libraries and XMLs.
--stop
Sends a stop signal to the running Jetty instance.
The running Jetty instance must have been started with a
stop.port=<port> property and the --stop command must
be executed with the same property.
--dry-run
Prints 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 by
a POSIX compliant shell. The parts are:
o "java" - the JVM to run
o "opts" - the JVM options (e.g. -D, -X and -XX flags)
o "path" - the JVM class-path and/or the JPMS module-path
o "main" - the main class to run
o "args" - the arguments passed to the main class
o "envs" - the generated XML files to create the environments
Configure Commands:
-------------------
--add-modules=<moduleName>(,<moduleName>)*
Adds the given modules to the list of modules enabled at
when Jetty starts.
Transitive dependencies are followed and dependent
modules 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 enables
the module, and any other option defined in the module's
[ini-template] section.
If the *.ini file specifies properties, these may be
overridden by specifying the same properties on the
command line.
If a module is transitively enabled, its *.ini file will
not be generated.
To generate the *.ini file, the module must be explicitly
listed in the --add-modules=... command.
This option replaces the deprecated --add-to-start and
--add-to-startd commands.
--create-start-d
Creates a ${jetty.base}/start.d directory.
If the ${jetty.base}/start.ini file exists, then it is
moved into the ${jetty.base}/start.d/ directory.
Using a ${jetty.base}/start.d/ directory is the default and
this option is only needed to either force the creation of
the ${jetty.base}/start.d/ directory, or to move a
${jetty.base}/start.ini file to ${jetty.base}/start.d/.
--create-start-ini
Creates a ${jetty.base}/start.ini file.
If a ${jetty.base}/start.d/ directory exists, then all
the contained *.ini files are concatenated into the
${jetty.base}/start.ini file.
--update-ini
Scans all the ${jetty.base}/start.d/*.ini files and updates
any property with values specified on the command line.
For example:
$ java -jar ${jetty.host}/start.jar --update-ini jetty.http.port=8888
--create-files
Creates any missing files that are required by enabled
modules, as specified in their [files] section.
This may download a file from the network if a HTTP URI
is specified in the [files] section.
--write-module-graph=<filename>
Creates a graphviz *.dot file of the module graph as it
is configured for the current ${jetty.base}.
See https://graphviz.org/ for details on how to post-process
this 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.ini
file or in ${jetty.base}/start.d/*.ini files created by
the --add-modules command.
--libs=<classpath>
Adds the specified class-path entries to the the server
class-path (or module-path).
--download=<http-uri>|<location>
Downloads a file from the given HTTP URI, if it does
not 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 in
some shell environments.
--exec
Executes the generated command line in a forked JVM
(see the --dry-run command).
This can be used when ${jetty.base}/start.d/*.ini files
contain -D, -X or -XX arguments, but creates an extra
JVM process.
--exec-properties=<filename>
Assigns a fixed name to the file used to transfer
properties to the sub process. This allows the
generated 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 the
JVM command line.
--jpms
Starts 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 directories
are set on the forked JVM class-path.
The main class is specified with the JPMS option
--module <moduleName>/<mainClassName>.
--debug
Enables 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 the
available logging modules using the --add-modules command.
--start-log-file=<filename>
A filename, relative to ${jetty.base}, where all startup
output will be sent. This is useful for capturing startup
issues when the Jetty logging module has not yet started
due to configuration errors.
--allow-insecure-http-downloads
Allow the use of insecure `http://` scheme for content download.
--approve-all-licenses
Approves all license questions from modules that have
particular license requirements.
Useful for enabling modules from a script, so that it
does 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 *.properties
config 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 sits
at a layer between ${jetty.home} and ${jetty.base}.
Useful when you want to apply a common "corporate"
configuration to all specific ${jetty.base} directories
without 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 is
running (defaults to 127.0.0.1).
stop.port=<number>
Used with the --stop command.
Specifies the port to use to contact the Jetty server
to 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 the
running 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 same
property 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 and
added 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 resolved
from 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, http
Depend: server
XML: etc/jetty-http.xml
Enabled: ${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
Jetty使用入门的更多相关文章
- Servlet引擎Jetty之入门1
Jetty与tomcat一样,HttpWeb容器,支持实现Servlet规范. 详细介绍参考:https://www.ibm.com/developerworks/cn/java/j-lo-jetty ...
- Jetty入门
Jetty的入门 一.开发环境 Eclipse 4.3.1 Maven 3.1 Jetty 9.0.6.v20130930 Jetty的下载地址: http://download.eclipse ...
- Jetty官方文档翻译
最近在学习Jetty,没有找到合适的资料,所有只能看官方文档了,但是只有英文的,想着自己翻译着学也是学还不如把学习的过程放到网上,也可以给需要的人看,英文水平毕竟有限,也是用有道翻译着来的,不过也加了 ...
- Jetty入门(1-3)Eclipse集成gradle-Gretty插件或maven-jetty插件运行应用
英文来源: http://akhikhl.github.io/gretty-doc/Getting-started.html 一.gradle插件 1.使用gretty来运行jetty: gradl ...
- Jetty入门(1-2)eclipse集成jetty插件并发布运行应用
一.eclipse集成jetty插件 1.从市场安装jetty插件 2.使用jetty插件发布应用和配置运行环境 debug配置默认共用上述run配置 3.使用jetty插件启动运行和停止运行选中的应 ...
- Jetty入门(1-1)Jetty入门教程
一.Jetty是什么? 1.Jetty 是一个Java语言编写的,开源的Servlet容器和应用服务器. Jetty 极度轻量级.高便携性.功能强大.灵活和扩展性好,而且支持各种技术如SPDY.Web ...
- jetty 入门
jetty因其能作为内嵌的应用服务器,随应用一起存在,在小批量应用中很受欢迎. jetty作为应用服务器: jetty下载: 在官网下载jetty:http://www.eclipse.org/jet ...
- Jenkins入门系列之——02第二章 Jenkins安装与配置
2014-12-08:已不再担任SCM和CI的职位,Jenkins的文章如无必要不会再维护. 写的我想吐血,累死了. 网页看着不爽的,自己去下载PDF.有问题请留言! Jenkins入门系列之——03 ...
- Jetty使用教程(四:28-30)—Jetty开发指南
二十八.延续机制支持 28.1 延续简介 延续是一种机制用来实现类似于Servlet 3.0异步功能的异步Servlet,但提供了一个简单易操作的接口. 28.1.1 为什么使用异步Servlets ...
- Jetty使用教程(四:24-27)—Jetty开发指南
二十四.处理器(Handler ) 24.1 编写一个常用的Handler Jetty的Handler组件用来处理接收到的请求. 很多使用者不需要编写Jetty的Handler ,而是通过使用Serv ...
随机推荐
- toml格式配置文件介绍
toml官方wik toml官方文档 此次文档是以v1.0.0为例,进行说明的.如果使用到的版本不同,直接去官方文档中找对应的版本即可. 谈到配置文件,大家都能说出来好几种,比如常见的ini.xml. ...
- elasticsearch 查询索引和清理索引命令
查询 curl --silent 'http://127.0.0.1:9200/_cat/indices' 删除 curl -X DELETE "localhost:9200/wifiloc ...
- 图数据库实操:用 Nebula Graph 破解成语版 Wordle 谜底
本文首发于 Nebula Graph Community 公众号 春节期间如果有小伙伴玩过 Wordle 这个火爆社交媒体的猜词游戏,可能对成语版本的汉兜有所耳闻.在玩汉兜过程中,我发现用 Nebul ...
- Java 方法的重载(overload)
1 /* 2 * 3 * 方法的重载(overload) 4 * 1.定义:在同一个类中,允许存在一个以上的同名方法,只要他们的参数个数或者参数类型不同 5 * 6 * "两同一不同&quo ...
- Java 从键盘输入不确定的整数 并判断读入的整数和负数的个数,输入0时候结束
1 /** 2 * 从键盘输入不确定的整数 并判断读入的整数和负数的个数,输入0时候结束 3 * 4 */ 5 6 Scanner scan = new Scanner(System.in); 7 8 ...
- body标签下莫名奇妙多了一行空行,原来是编码的问题
之前为了方便,直接在服务器修改文件,然后点保存,但是问题来了,在顶部莫名奇妙多了一个空行,如图1 图1 原来在源代码编辑的代码如图2 图2 但是在FF或者Chrome外部样式却在body里面,而不是h ...
- 使用 Docker 部署 Fiora 在线聊天室平台
一.Fiora 介绍 Fiora 简介 Fiora 是一款开源免费的在线聊天系统. GitHub:https://github.com/yinxin630/fiora Fiora 功能 注册账号并登录 ...
- Zabbix“专家坐诊”第198期问答汇总
问题一 Q:请问一下,自带的思科SNMP交换机模板,怎么不监控down的接口? A1:这种一般在自动发现规则里加个过滤器,过滤出IFSTATUS匹配(1|3)的就能实现只发现up的端口了. A2: 1 ...
- linux下,使用nginx实现动静分离,访问图片报404
一.需求描述 最近在开发一个微信小程序,由于微信小程序端代码包总大小限定在三四兆,所以有很多的图标资源就不能放在微信小程序中进行打包, 否则会超过微信的限制而无法打包.自己能够想到的最简单的办法就是将 ...
- 提升地理空间分析效率,火山引擎ByteHouse上线GIS能力
更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 在数字化时代,地理空间分析(Geospatial Analytics)成为辅助企业市场策略洞察的重要手段.无论是广 ...