public class SpringContainer implements Container {private static final Logger logger = LoggerFactory.getLogger(SpringContainer.class);public static final String SPRING_CONFIG = "dubbo.spring.config";public static final String DEFAULT_SPRING_CONFIG = "classpath*:spring/*.xml";static ClassPathXmlApplicationContext context;public static ClassPathXmlApplicationContext getContext() {return context;}public void start() {String configPath = ConfigUtils.getProperty(SPRING_CONFIG);if (configPath == null || configPath.length() == 0) {configPath = DEFAULT_SPRING_CONFIG;}context = new ClassPathXmlApplicationContext(configPath.split("[,\\s]+"));context.start();}public void stop() {try {if (context != null) {context.stop();context.close();context = null;}} catch (Throwable e) {logger.error(e.getMessage(), e);}}}测试:package com.mushsoft.service.order.provider;import com.mushsoft.framework.HelperLoader;/*** 主线程启动*/public class TestMain {public static void main(String[] args) throws Exception {com.alibaba.dubbo.container.Main.main(args);}}
java如何使用dubbo_你真的知道Dubbo服务用Main方法是如何启动的吗?
最新推荐文章于 2022-04-01 08:56:03 发布