The service container of Dubbo 3 is a standalone startup program, because the background service does not need the functions of web containers such as Tomcat or JBoss. If you insist on using the web container to load the service provider, it will increase complexity and waste resources. Therefore, services usually do not require the features of web containers such as Tomcat/JBoss, and there is no need to use web containers to load services.
The Dubbo3 service container is just a simple Main method and loads a simple Spring container for exposing services.
The loading content of the service container can be extended, and spring, jetty, log4j, etc. are built-in, and can be extended through container extension point. The configuration is configured in the -D parameter of the java command or dubbo.properties
.
The web container is mainly used to respond to http requests and static pages. The Dubbo service provider only provides dubbo services externally. It is not suitable to use the web container. As a dubbo service provider alone, it only needs to load a simple spring container through a main method Expose the service.
Autoload all Spring configurations under the META-INF/spring
directory.
Configure the spring configuration loading location:
dubbo.spring.config=classpath*:META-INF/spring/*.xml
dubbo.jetty.port=8080
: configure jetty startup portdubbo.jetty.directory=/foo/bar
: Configure a directory that can be directly accessed through jetty to store static filesdubbo.jetty.page=log,status,system
: configure the displayed pages, all pages are loaded by defaultdubbo.log4j.file=/foo/bar.log
: configure log file pathdubbo.log4j.level=WARN
: configure log leveldubbo.log4j.subdirectory=20880
: Configure the log subdirectory for multi-process startup to avoid conflictsOnly spring is loaded by default
java org.apache.dubbo.container.Main
Pass in the container to be loaded through the main function parameter
java org.apache.dubbo.container.Main spring jetty log4j
Pass in the container to be loaded through the JVM startup parameters
java org.apache.dubbo.container.Main -Ddubbo.container=spring,jetty,log4j
Pass in the container to be loaded through dubbo.properties
configuration under the classpath
dubbo.container=spring,jetty,log4j