Jetty Application Server Installation Details, jetty server details
Jetty is an open-source Servlet container and application server. It is extremely lightweight, highly portable, powerful, flexible, and scalable, it also supports various technologies such as SPDY, WebSocket, OSGi, JMX, JNDI, and JAAS. Jetty is very convenient for development and has been widely used in production environments. This article describes how to install and configure the Jetty server, and describes the Standalone mode of Jetty ). Next, we will introduce its configuration options and modular architecture.
Jetty has independent running mode, embedded running mode, and Jetty Maven plug-in operation mode. This document uses the independent running mode.
I. Deployment Environment
Two software:
1. Java 8u60
Http://download.oracle.com/otn-pub/java/jdk/8u60-b27/jdk-8u60-windows-x64.exe
2. Jetty 9.3.2
Http://eclipse.org/downloads/download.php? File =/jetty/stable-9/dist/jetty-distribution-9.3.2.v20150730.zip & r = 1
Earlier versions can also be used, but the latest version should be used as much as possible.
Jetty is a cross-platform software, so its binary release package can be applied to multiple platforms.
Ii. deployment and operation
Download and decompress Jetty, enter the decompressed directory of Jetty, and run the following command:
java -jar start.jar
The output is as follows:
D:\Programs\jetty9>java -jar start.jar2015-09-02 16:31:36.273:INFO::main: Logging initialized @2060ms2015-09-02 16:31:36.696:WARN:oejs.HomeBaseWarning:main: This instance of Jetty is not running from a separate {jetty.base} directory, this is not recommended. See documentation at http://www.eclipse.org/jetty/documentation/current/startup.html2015-09-02 16:31:37.228:INFO:oejs.Server:main: jetty-9.3.2.v201507302015-09-02 16:31:37.302:INFO:oejdp.ScanningAppProvider:main: Deployment monitor [file:///D:/Programs/jetty9/webapps/] at interval 12015-09-02 16:31:37.701:INFO:oejs.ServerConnector:main: Started ServerConnector@3b81a1bc{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}2015-09-02 16:31:37.704:INFO:oejs.Server:main: Started @3491ms
Visit the address http: // localhost: 8080/in a browser. You can see
3. Run the Jetty Web Application
Deploying a war project on the Jetty application server is simple. You only need to put the project war package into the webapps subdirectory of Jetty. You do not need to restart Jetty. Jetty automatically listens to the webapps directory at any time to automatically deploy new projects.
Iv. Jetty directory Analysis
Bin: executable script file
Demo-base:
Etc: directory of the XML configuration file defined by the Jetty Module
Lib: library files dependent on Jetty
Logs: Jetty's log directory
Modules: Jetty Module
Resources: directory of the external resource configuration file
Webapps: directory of the Project WAR File
You also need to pay attention to a file in the root directory: start. d (the Wondows system is the start. INIFILE), which defines the Jetty activity module.
5. basic configuration 1. Modify the Jetty Port
Jetty uses port 8080 by default. To enable it to use another port (such as port 7070), edit start. d (Wondows system is start. INI file), find jetty. http. port line, changed:
## Connector port to listen onjetty.http.port=7070
Save and exit, and restart Jetty.
2. Modify the webapps directory
Webapps under Jetty is the default deployment directory of Web projects. To modify this directory, you can modify start. d configuration file (start. ini), remove the annotator "#" from the following line
# jetty.deploy.monitoredDir=webapps
And modify the content to the specified directory. Save and exit, and restart Jetty.
Vi. Jetty's modular architecture
Jetty runs on a modular architecture, which means that Jetty's functions are run in the form of modules, such as HTTP, HTTPS, SSL, log logging, JMX, JNDI, WebSocket and other modules. Common modules such as HTTP, JSP, and WebSocket are activated by default, while other modules such as HTTPS and JMX need to be manually activated.
1. Analysis of a single module
Jetty's modules sub-directory lists all modules whose extensions are. mod file, which declares the JAR file to be activated (under the lib subdirectory of Jetty) and XML configuration file (under the etc subdirectory of Jetty ), and other resources to be activated as modules.
For example, you can view the logging of the modules subdirectory. mod file content, you can see that it declares the configuration file is etc/jetty-logging.xml, the required JAR package in lib/logging, and the logs directory is required.
[ xml]etc/jetty-logging.xml[files]logs/[lib]lib/logging/**.jarresources/
2. Activate the module through command line
There are two ways to activate Jetty modules.
Java-jar start. jar -- add-to-startd = logging
The above command will create the logging. ini file in the Jetty directory. The related configuration can be found in this file. After configuring the log, you can start Jetty again and check that the Log Module is activated.
2. Activate the module through the configuration file start. ini.
The second method is to activate the module through the configuration file start. ini.
--module=logging
This method is similar to the previous one and is more commonly used.
3. Configuration Module
As mentioned above, the mod file declares the relevant XML configuration file. Under the etc subdirectory of Jetty, you can use these configuration files to configure the module. For example, if the Log Module declares that the related configuration file is a jetty-logging.xml, you can modify this configuration file to adjust the log.
To learn more about the content, read the official documentation.
Http://www.eclipse.org/jetty/documentation/current/index.html
Source: http://blog.csdn.net/chszs/article/details/48186139