配置方式一xml
在resources目录dubbo-provider.xml
配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd"> <dubbo:application name="dubbo-provider"/> <dubbo:protocol name="dubbo" port="20880"/> <dubbo:service interface="exxk.dubbo.commonimpl.DemoService" ref="demoService"/> <bean id="demoService" class="exxk.dubbo.provider.impl.DemoServiceImpl"/> </beans>
|
需要在dubbo启动器指向xml名字
1 2 3
| ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext( new String[]{"dubbo-provider.xml"}); context.start();
|
配置方式二dubbo.properties
注:配置文件名字是固定的
1
| dubbo.registry.address=zookeeper://10.14.1.7:2181
|
配置方式三jvm
注:gradle application task run启动vm设置无效
1
| -Ddubbo.registry.address=zookeeper://10.14.1.7:2181
|
覆盖策略
JVM>XML>Properties其中jvm优先级最高