本文使用的是dubbo提供的主类com.alibaba.dubbo.container.Main启动容器。
主要区别是提供不同插件的的启动方式。
目录
一、项目内容
1.1、目录结构图
1.2、相关文件配置
二、运行容器方式
2.1 使用Java命令启动(手动)
2.1.1 使用maven-shade-plugin 插件打包运行
2.1.2 使用 maven-jar-plugin 插件和 maven-dependency-plugin 插件打包运行
2.2 使用脚本启动
2.2.1 windows启动脚本start.bat
2.2.2 linux启动脚本start.sh
2.2.3 linux停止脚本stop.sh
2.2.4 linux重启脚本restart.sh
一、项目内容
1.1 目录结构如图:
1.2 相关文件的配置
DemoService
package com.test.provider;
/**
* Created by Administrator on 2018/2/1.
*/
public interface DemoService {
String sayHello(String word);
}
DemoServiceImpl
package com.test.provider;
import org.springframework.stereotype.Service;
/**
* Created by Administrator on 2018/2/1.
*/
@Service("demoService")
public class DemoServiceImpl implements DemoService {
public String sayHello(String word) {
return "hello " + word + ",I'm provider \r\n";
}
}
assemble-descriptor.xml
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
bin
tar.gz
zip
true
src/main/resources/bin
bin
*
0755
true
src/main/resources/cconf
cconf
*
0755
true
lib
true
false
runtime
application.xml
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
dubbo-provider.xml
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xmlns:context="http://www.springframework.org/schema/context"
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 http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
dubbo.properties
#把属行放在该文件主要是为了方便使用脚本启动时,获取以下的信息
dubbo.application.name=hello-provider
dubbo.protocol.name=dubbo
dubbo.protocol.port=20880
pom.xml
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
com.jay.test.dubbo-zookeeper
hello-provider
1.0-SNAPSHOT
jar
4.3.8.RELEASE
com.alibaba
dubbo
2.5.9
org.springframework
spring
org.apache.zookeeper
zookeeper
3.4.10
com.github.sgroschupf
zkclient
0.1
org.springframework
spring-core
${spring.version}
org.springframework
spring-context
${spring.version}
org.springframework
spring-beans
${spring.version}
org.springframework
spring-context-support
${spring.version}
org.springframework
spring-aop
${spring.version}
org.springframework
spring-tx
${spring.version}
org.springframework
spring-web
${spring.version}
org.springframework
spring-webmvc
${spring.version}
org.springframework