dubbo 提供者启动报错;Dubbo启动异常:Duplicate application config...{{1030}}

dubbo 提供者启动报错
java -jar lp-provider-1.0-SNAPSHOT.jar
[13/06/18 03:49:51:051 CST] main  INFO logger.LoggerFactory: using logger: com.alibaba.dubbo.common.logger.log4j.Log4jLoggerAdapter
[13/06/18 03:49:51:051 CST] main  INFO container.Main:  [DUBBO] Use container type([spring]) to run dubbo serivce., dubbo version: 2.5.3, current host: 127.0.0.1
[13/06/18 03:49:51:051 CST] main  INFO support.ClassPathXmlApplicationContext: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@3c679bde: startup date [Wed Jun 13 15:49:51 CST 2018]; root of context hierarchy
[13/06/18 03:49:51:051 CST] main  INFO xml.XmlBeanDefinitionReader: Loading XML bean definitions from URL [jar:file:/D:/jar%20target/lp-provider-1.0-SNAPSHOT.jar!/META-INF/spring/limp-dubbo-context.xml]
[13/06/18 03:49:52:052 CST] main  INFO xml.XmlBeanDefinitionReader: Loading XML bean definitions from class path resource [META-INF/spring/limp-dubbo-provider.xml]
[13/06/18 03:49:52:052 CST] main  INFO xml.XmlBeanDefinitionReader: Loading XML bean definitions from class path resource [META-INF/spring/limp-dubbo-mybatis.xml]
[13/06/18 03:49:52:052 CST] main  INFO xml.XmlBeanDefinitionReader: Loading XML bean definitions from class path resource [META-INF/spring/limp-dubbo-uums-mybatis.xml]
[13/06/18 03:49:52:052 CST] main  INFO xml.XmlBeanDefinitionReader: Loading XML bean definitions from URL [jar:file:/D:/jar%20target/lp-provider-1.0-SNAPSHOT.jar!/META-INF/spring/limp-dubbo-mybatis.xml]
[13/06/18 03:49:52:052 CST] main  INFO xml.XmlBeanDefinitionReader: Loading XML bean definitions from URL [jar:file:/D:/jar%20target/lp-provider-1.0-SNAPSHOT.jar!/META-INF/spring/limp-dubbo-provider.xml]
[13/06/18 03:49:52:052 CST] main  INFO xml.XmlBeanDefinitionReader: Loading XML bean definitions from URL [jar:file:/D:/jar%20target/lp-provider-1.0-SNAPSHOT.jar!/META-INF/spring/limp-dubbo-uums-mybatis.xml]
[13/06/18 03:49:52:052 CST] main  INFO xml.XmlBeanDefinitionReader: Loading XML bean definitions from URL [jar:file:/D:/jar%20target/lib/common-config-1.0-SNAPSHOT.jar!/META-INF/spring/limp-plug-spring-common.xml]
[13/06/18 03:49:52:052 CST] main  WARN mapper.ClassPathMapperScanner: Skipping MapperFactoryBean with name 'serviceParamsMapper' and 'com.limp.dubbo.boss.mapper.oracle.ServiceParamsMapper' mapperInterface. Bean already defined with the same name!
[13/06/18 03:49:52:052 CST] main  WARN mapper.ClassPathMapperScanner: Skipping MapperFactoryBean with name 'servicesMapper' and 'com.limp.dubbo.boss.mapper.oracle.ServicesMapper' mapperInterface. Bean already defined with the same name!
[13/06/18 03:49:52:052 CST] main  WARN mapper.ClassPathMapperScanner: Skipping MapperFactoryBean with name 'userInfoMapper' and 'com.limp.dubbo.boss.mapper.oracle.UserInfoMapper' mapperInterface. Bean already defined with the same name!
[13/06/18 03:49:52:052 CST] main  WARN mapper.ClassPathMapperScanner: No MyBatis mapper was found in '[com.limp.dubbo.boss.mapper.oracle]' package. Please check your configuration.
[13/06/18 03:49:52:052 CST] main  WARN mapper.ClassPathMapperScanner: Skipping MapperFactoryBean with name 'uumsPortMapper' and 'com.limp.dubbo.boss.mapper.uums.UumsPortMapper' mapperInterface. Bean already defined with the same name!
[13/06/18 03:49:52:052 CST] main  WARN mapper.ClassPathMapperScanner: No MyBatis mapper was found in '[com.limp.dubbo.boss.mapper.uums]' package. Please check your configuration.
[13/06/18 03:49:52:052 CST] main  INFO config.PropertyPlaceholderConfigurer: Loading properties file from class path resource [jdbc.properties]
[13/06/18 03:49:52:052 CST] main  INFO config.PropertyPlaceholderConfigurer: Loading properties file from class path resource [service.properties]
[13/06/18 03:49:52:052 CST] main  INFO annotation.AutowiredAnnotationBeanPostProcessor: JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
[13/06/18 03:49:52:052 CST] main ERROR pool.DruidAbstractDataSource: maxIdle is deprecated
[13/06/18 03:49:53:053 CST] main ERROR pool.DruidDataSource: invalid oracle validationQuery. SELECT 1, may should be : SELECT 1 FROM DUAL
[13/06/18 03:49:53:053 CST] main  INFO pool.DruidDataSource: {dataSource-1} inited
[13/06/18 03:49:53:053 CST] main ERROR pool.DruidAbstractDataSource: maxIdle is deprecated
[13/06/18 03:49:53:053 CST] main ERROR pool.DruidDataSource: invalid oracle validationQuery. SELECT 1, may should be : SELECT 1 FROM DUAL
[13/06/18 03:49:53:053 CST] main  INFO pool.DruidDataSource: {dataSource-2} inited
[13/06/18 03:49:54:054 CST] main  WARN support.ClassPathXmlApplicationContext: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.limp.dubbo.boss.service.UserInfoService': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Duplicate application configs:  and 
[13/06/18 03:49:54:054 CST] main  INFO pool.DruidDataSource: {dataSource-2} closed
[13/06/18 03:49:54:054 CST] main  INFO pool.DruidDataSource: {dataSource-1} closed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.limp.dubbo.boss.service.UserInfoService': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Duplicate application configs:  and 
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
        at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
        at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:93)
        at com.alibaba.dubbo.container.spring.SpringContainer.start(SpringContainer.java:50)
        at com.alibaba.dubbo.container.Main.main(Main.java:80)
Caused by: java.lang.IllegalStateException: Duplicate application configs:  and 
        at com.alibaba.dubbo.config.spring.ServiceBean.afterPropertiesSet(ServiceBean.java:164)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
        ... 13 more
[13/06/18 03:49:54:054 CST] main ERROR container.Main:  [DUBBO] Error creating bean with name 'com.limp.dubbo.boss.service.UserInfoService': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Duplicate application configs:  and , dubbo version: 2.5.3, current host: 127.0.0.1
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.limp.dubbo.boss.service.UserInfoService': Invocation of init method failed; nested exception is java.lang.IllegalStateException: Duplicate application configs:  and 
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
        at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:139)
        at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:93)
        at com.alibaba.dubbo.container.spring.SpringContainer.start(SpringContainer.java:50)
        at com.alibaba.dubbo.container.Main.main(Main.java:80)
Caused by: java.lang.IllegalStateException: Duplicate application configs:  and 
        at com.alibaba.dubbo.config.spring.ServiceBean.afterPropertiesSet(ServiceBean.java:164)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
        ... 13 more
[13/06/18 03:49:54:054 CST] DubboShutdownHook  INFO config.AbstractConfig:  [DUBBO] Run shutdown hook now., dubbo version: 2.5.3, current host: 127.0.0.1
[13/06/18 03:49:54:054 CST] DubboShutdownHook  INFO support.AbstractRegistryFactory:  [DUBBO] Close all registries [], dubbo version: 2.5.3, current host: 127.0.0.1

分析问题:

原因是加载了2次配置文件


之前的错误配置如下:在limp-dubbo-context.xml 又导入了其他的3个配置文件,启动provider时候导致多次加载;

猜测:provider启动的时候加载的是 META-INF/spring/*.xml 下的所有配置文件。

dubbo 提供者启动报错;Dubbo启动异常:Duplicate application config...{{1030}}_第1张图片


解决方案:注释掉导入配置的文件即可

dubbo 提供者启动报错;Dubbo启动异常:Duplicate application config...{{1030}}_第2张图片



-----------------------------------------------其他技能点---------------------------------------------------------

provider(开发环境)启动配置类,可以这么配置

/**
 * @author:shinians email:[email protected]
 * @description:
 * @date:Created in 17:30 2018/5/24
 * @modified By:
 */
public class BossProviderStart {

    private static final Log log = LogFactory.getLog(BossProviderStart.class);

    public static void main(String[] args) throws IOException {
        try {
//            ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/limp-dubbo-provider.xml"});
            ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/limp-dubbo-context.xml"
                    ,"META-INF/spring/limp-dubbo-mybatis.xml" ,"META-INF/spring/limp-dubbo-provider.xml","META-INF/spring/limp-dubbo-uums-mybatis.xml"});
            System.out.println(context.getDisplayName() + ": here");
            context.start();
            System.out.println("服务已经启动...");
            //按任意键退出
            System.in.read();
        } catch (Exception e) {
            log.error("== DubboProvider context start error:", e);

        }
    }
}



-----------------------------------------pom打包插件可以参考如下-------------------------------------------------------------


    
        
        
            
                ${project.build.directory}/classes
                src/main/resources
                true
                
                    **/*.xml
                    **/*.properties
                
            
            
            
                ${project.build.directory}/classes/META-INF/spring
                src/main/resources/META-INF/spring
                true
                
                    limp-dubbo-context.xml
                
            
        

        
            
                
                
                    org.eclipse.m2e
                    lifecycle-mapping
                    1.0.0
                    
                        
                            
                                
                                    
                                        org.apache.maven.plugins
                                        maven-dependency-plugin
                                        [2.0,)
                                        
                                            copy-dependencies
                                        
                                    
                                    
                                        
                                    
                                
                            
                        
                    
                
            
        
        
            
            
                org.apache.maven.plugins
                maven-jar-plugin
                
                    target/classes/
                    
                        
                            com.alibaba.dubbo.container.Main
                            
                            false
                            true
                            lib/
                        
                        
                            .
                        
                    
                
            
            
                org.apache.maven.plugins
                maven-dependency-plugin
                
                    
                        copy-dependencies
                        package
                        
                            copy-dependencies
                        
                        
                            jar
                            jar
                            

                            
                                ${project.build.directory}/lib
                            
                        
                    
                
            
        

    


你可能感兴趣的:(Dubbo)