dubbo服务启动方式对比

Dubbo服务的运行方式

1、使用Servlet容器(Tomcat、Jetty等)运行

缺点:增加复杂性(端口、管理) 浪费资源(内存)
2、自建main方法类来运行(Spring容器)

缺点: Dobbo本身提供的高级特性没用上 自已编写启动类可能会有缺陷
3、使用Dubbo框架提供的Main方法类来运行(Spring容器)

优点:框架本身提供(com.alibaba.dubbo.container.Main) 可实现优雅关机(ShutdownHook)
建议使用这种方式


    user-service
    
        
            ${project.build.directory}/classes
            src/main/resources
            true
            
                **/*.xml
                **/*.properties
            
        
        
        
            ${project.build.directory}/classes/META-INF/spring
            src/main/resources/spring
            true
            
                spring-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
                        false
                        
                            ${project.build.directory}/lib
                        
                    
                
            
        
    


4、定位到相应的目录下,执行命令启动服务

java -jar user-service.jar &

5、如果服务采用war包,直接部署在tomcat就ok了。

 

 


    user-service
    
        
            ${project.build.directory}/classes
            src/main/resources
            true
            
                **/*
            
        
        
        
            ${project.build.directory}/classes/META-INF/spring
            src/main/resources/spring
            true
            
                spring.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-compiler-plugin
            3.1
            
                1.8
                1.8
                UTF-8
                
                    -extdirs
                    ${project.basedir}/src/main/webapp/WEB-INF/lib
                
            
        
        
            org.apache.maven.plugins
            maven-war-plugin
            2.6
            
                user-service
                
                    false
                
            
        
    

 

 

 

 

 

 

你可能感兴趣的:(dubbo)