You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by "shifefiei (GitHub)" <gi...@apache.org> on 2019/12/08 12:08:47 UTC

[GitHub] [dubbo] shifefiei opened issue #5439: 无法解析站位符

2019-12-08 19:59:12.987|WARN|main-SendThread()|org.apache.zookeeper.ClientCnxn - Session 0x0 for server ${dubbo.zk.host}:9090, unexpected error, closing socket connection and attempting reconnect
java.lang.IllegalArgumentException: named capturing group is missing trailing '}'
	at java.util.regex.Matcher.appendReplacement(Matcher.java:841) ~[na:1.8.0_191]
	at java.util.regex.Matcher.replaceAll(Matcher.java:955) ~[na:1.8.0_191]
	at java.lang.String.replaceAll(String.java:2223) ~[na:1.8.0_191]
	at org.apache.zookeeper.ClientCnxn$SendThread.startConnect(ClientCnxn.java:997) ~[zookeeper-3.4.13.jar!/:3.4.13-2d71af4dbe22557fda74f9a9b4309b15a7487f03]
	at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1064) ~[zookeeper-3.4.13.jar!/:3.4.13-2d71af4dbe22557fda74f9a9b4309b15a7487f03]

[ Full content available at: https://github.com/apache/dubbo/issues/5439 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [dubbo] shifefiei commented on issue #5439: 无法解析站位符

Posted by "shifefiei (GitHub)" <gi...@apache.org>.
为题已解决,谢谢
package com.xrxs.attendance.entry.config;

import com.alibaba.dubbo.config.RegistryConfig;
import org.springframework.beans.BeansException;
import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanDefinitionRegistryPostProcessor;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/**
 * Created by sff on 2019-12-13 21:03
 */
@Component
public class AttendanceDubboRegistry implements BeanDefinitionRegistryPostProcessor, EnvironmentAware {

    @Autowired
    private Environment env;

    @Override
    public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
        BeanDefinition registryConfig = registry.getBeanDefinition("com.alibaba.dubbo.config.RegistryConfig");
        String address = env.getProperty("dubbo.zk.host");
        String group = env.getProperty("dubbo.zk.group");
        group = "dubbo/" + group;

        MutablePropertyValues propertyValues = registryConfig.getPropertyValues();
        propertyValues.add("address", address);
        propertyValues.add("group", group);
    }

    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        RegistryConfig registryConfig = beanFactory.getBean(RegistryConfig.class);

        String group = env.getProperty("dubbo.zk.group");
        group = "dubbo/" + group;

        String address = env.getProperty("dubbo.zk.host");
        registryConfig.setAddress(address);
        registryConfig.setGroup(group);
    }

    @Override
    public void setEnvironment(Environment environment) {
        this.env = environment;
    }
}
自己手动注册解析进去

[ Full content available at: https://github.com/apache/dubbo/issues/5439 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org

[GitHub] [dubbo] CodingSinger commented on issue #5439: 无法解析站位符

Posted by "CodingSinger (GitHub)" <gi...@apache.org>.
Can you describe it specifically?

[ Full content available at: https://github.com/apache/dubbo/issues/5439 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org


[GitHub] [dubbo] kimmking commented on issue #5439: 无法解析站位符

Posted by "kimmking (GitHub)" <gi...@apache.org>.
is a spring config issue? @shifefiei 


[ Full content available at: https://github.com/apache/dubbo/issues/5439 ]
This message was relayed via gitbox.apache.org for notifications@dubbo.apache.org