dawdler-boot-web
Module Introduction
Root module of the embedded dawdler-web container. It provides annotations, configuration, component providers, starters and more. Developers normally do not need to use this module unless they want to extend it with another container such as jetty or tomcat.
1. Common configuration
- undertow.yml, tomcat.yml (these two containers are currently supported). Located under resources.
server:
http-enabled: true # whether to enable the HTTP connector
host: 192.168.1.188 # web address of the web container, empty by default, binds 0.0.0.0
port: 8080 # port the web container serves HTTP requests on, 8080 by default
http2: false # whether to support http2, false by default
graceful-shutdown: true # whether to shut down gracefully, true by default
graceful-shutdown-timeout: 30000 # wait time for graceful shutdown in milliseconds, 30000 by default
# SSL configuration, used to start the https service
ssl:
ssl-enabled: true # whether to enable SSL
ssl-port: 8443 # HTTPS port (default: 8443)
ssl-keystore-file: keystore.jks # keystore file path, supports absolute and relative paths; relative paths are resolved under resources
ssl-keystore-password: changeit # keystore password
ssl-keystore-type: JKS # keystore type (default: JKS)
ssl-key-alias: tomcat # key alias
ssl-key-password: changeit # key password
ssl-protocol: TLS # SSL protocol (default: TLS)
context-path: user-api # web context-path, empty by default; if set to user-api, access http://localhost:8080/user-api/xxx; if not set, http://localhost:8080/xxx
deploy-name: user-api # web deploy-name, empty by default
static-location: static # location of the web static resources, not bound by default; used to hold html, jsp, images, js scripts and so on
component-package-paths: # package paths for scanning servlet components, antpath is supported; supports filter, servlet, listener and @HandlesTypes in ServletContainerInitializer, and supports injecting other components into global fields such as service, mq, redis, schedule, etc.
- com.xxx.listener
- com.xxx.servlet
error-pages: # error page definitions, error status code -> error page file
500: /500.html
404: /404.html
compression:
enabled: false # whether to enable compression; only effective when the frontend proxy server or browser supports it, i.e. the request header contains Accept-Encoding: gzip, deflate
mime-types: # supported types by default, optional; fill in to extend
- text/html
- text/xml
- text/plain
- text/css
- text/javascript
- application/javascript
- application/json
- application/xml
min-response-size: 65536 # compression threshold in bytes, 65536 bytes (64kb) by default
-
logback.xml - logging configuration file
-
dawdler.cer - public key certificate. The default one can be used. To create a new one, see Creating a certificate with keytool
-
dawdler-config.yml - unified configuration center file. Required if the unified configuration center is used. See dawdler-config.yml
-
client-conf.xml - client-conf.xml configuration, scan component package configuration, remote loading components
2. Configure the bootstrap class
package com.dawdler.user.application;
import club.dawdler.boot.web.annotation.DawdlerBootApplication;
import club.dawdler.boot.web.starter.DawdlerWebApplication;
@DawdlerBootApplication
public class UserWebApplication {
public static void main(String[] args) throws Throwable {
DawdlerWebApplication.run(UserWebApplication.class, args);
}
}
3. IDE startup arguments (JPMS)
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED --add-opens=java.base/jdk.internal.perf=ALL-UNNAMED --add-opens=java.base/jdk.internal.misc=ALL-UNNAMED --add-opens=java.xml/com.sun.org.apache.xerces.internal.dom=ALL-UNNAMED
4. Running the fat-jar packaged with dawdler-boot-maven-plugin (JPMS)
java --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED --add-opens=java.base/jdk.internal.perf=ALL-UNNAMED --add-opens=java.xml/com.sun.org.apache.xerces.internal.dom=ALL-UNNAMED --add-opens=java.base/jdk.internal.misc=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/jdk.internal.perf=dawdler.boot.classloader --add-opens=java.base/jdk.internal.loader=dawdler.boot.classloader --add-opens=java.base/jdk.internal.misc=dawdler.boot.classloader -p xxx-all.jar -m dawdler.boot.classloader
or
java --add-exports=java.base/sun.nio.ch=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED --add-opens=java.base/jdk.internal.perf=ALL-UNNAMED --add-opens=java.base/jdk.internal.misc=ALL-UNNAMED --add-opens=java.xml/com.sun.org.apache.xerces.internal.dom=ALL-UNNAMED -jar xxx-all.jar
5. Specifying ports at runtime
A startup argument takes precedence over a JVM system property.
5.1 Specify via a startup argument
--server.port=8081
--server.ssl.port=8443
5.2 Specify via a JVM system property
-Dserver.port=8081
-Dserver.ssl.port=8443