Skip to main content

dawdler-boot-server

Module Introduction​

Embedded dawdler-server container. Supports running via the main method in an IDE or as a fatjar built with the dawdler-boot-maven-plugin.

1. Usage​

Add the following to pom.xml:

<dependencies>
<dependency>
<groupId>club.dawdler</groupId>
<artifactId>dawdler-boot-server</artifactId>
</dependency>
</dependencies>

2. Configuration files​

The configuration files below live on the classpath, typically under the resources directory of your source code.

  1. dawdler.keystore - private key certificate. The default one can be used. To create a new one, see Creating a certificate with keytool

  2. dawdler-config.yml - unified configuration center file. Required if the unified configuration center is used. See dawdler-config.yml

  3. logback.xml - logging configuration file

  4. server-conf.xml - dawdler server configuration. To customize it, see dawdler-conf.xml

  5. services-conf.xml - basic service configuration, including the service scan paths, the data sources used when the unified configuration center is not used, the data source rule configuration and the data source binding service configuration

3. Configure the bootstrap class​

package com.dawdler.user.application;

import club.dawdler.boot.server.annotation.DawdlerBootApplication;
import club.dawdler.boot.server.starter.DawdlerServerApplication;
@DawdlerBootApplication(serviceName = "user-service") // service name
public class UserServiceApplication {
public static void main(String[] args) throws Exception {
DawdlerServerApplication.run(UserServiceApplication.class, args);
}
}

4. 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/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

5. 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/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 --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/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.base/java.nio=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.xml/com.sun.org.apache.xerces.internal.dom=ALL-UNNAMED -jar xxx-all.jar

6. Specifying ports at runtime​

A startup argument takes precedence over a JVM system property.

6.1 Specify the server port via a startup argument​

--server.port=9527

6.2 Specify the server port via a JVM system property​

-Dserver.port=9527

6.3 Specify the shutdown port via a startup argument​

--shutdown.port=19527

6.4 Specify the shutdown port via a JVM system property​

-Dshutdown.port=19527