Giter Site home page Giter Site logo

dapeng-hello's Introduction

Dapeng-hello

dapeng-soa 构建的hello服务(Java实现)

项目目录树

|--dapeng-hello
|  |--hello-api                 dapeng服务api,插件生成代码
|  |  |--src
|  |  |  |--main
|  |  |  |  |--java
|  |  |  |  |--resources
|  |  |  |  |  |--thrifts       IDL文件存放
|  |  |--pom.xml
|  |--hello-service             dapeng服务实现
|  |  |--src
|  |  |  |--main
|  |  |  |  |--java
|  |  |  |  |--resources
|  |  |  |  |  |--META-INF
|  |  |  |  |  |  |--spring
|  |  |  |  |  |  |  |--services.xml
|  |  |  |  |  |  |--services
|  |  |  |  |  |  |  |--com.github.dapeng.core.ApplicationContext   SpringBoot启动类
|  |  |--pom.xml
|  |  |--logs
|  |  |--docker
|  |  |  |--Dockerfile          
|  |--.gitignore
|  |--pom.xml
|  |--hello-test-clinet         客户端测试
------------------------------------

本地启动

本地启动需要本地启动 zookeeper ,可使用 docker 启动一个 zookeeper 容器

docker pull zookeeper
docker run --name zookeeper -p 2181:2181 --restart always -d zookeeper

Dapeng 插件启动服务

cd hello-service
mvn compile dapeng:run
或者
cd hello-service
mvn compile com.github.dapeng-soa:dapeng-maven-plugin:2.2.2:run -Dsoa.freq.limit.enable=false -Dsoa.apidoc.port=8192

注意:这里指定-Dsoa.apidoc.port=8192,为文档站点端口,浏览器打开http://localhost:8192即可访问

以SpringBoot形式进行开发

Dapeng 2.2.2 支持SpringBoot形式。具体案例请参考:com.dapeng.example.HelloServiceApp 类, 并将其注册到 META-INF/services/com.github.dapeng.core.ApplicationContext 文件

以Spring XML形式进行开发

Dapeng 支持以传统的 Spring XML 方式进行开发,此时,需要定义 META-INF/spring/services.xml 文件。

如果同时存在services/com.github.dapeng.core.ApplicationContext 定义和 META-INF/spring/services.xml,则优先使用前者。

本地测试

  • 客户端测试代码在hello-test-client,测试前确保服务已启动服务,运行HelloClientTest即可
  • 单元测试代码在hello-service,运行HelloTestCase即可

服务默认注册端口:9090 默认在线测试文档端口:8080,可使用-Dsoa.apidoc.port=8192指定站点端口

打开浏览器 http://localhost:8080 访问在线文档进行测试

打包docker镜像

cd hello-service
mvn clean package

使用docker-compose编排服务

使用docker-compose启动服务容器

docker-compose up -d helloZk
docker-compose up -d helloService

以上命令会一并启动一个依赖的 zookeeper 容器 helloZk ,无需单独启动 zookeeper

容器模式下启动服务没有在线测试站点,如果需要测试可以编写客户端服务来进行测试

use in SpringBoot mode

  1. uncomment file hello-service/src/main/resources/META-INF/services/com.github.dapeng.core.ApplicationContext
  2. uncomment @DapengService(service = HelloServiceImpl.class) annotation. Currently, can't using the Spring-XML mode with @DapengService.

Update 2021-08-02

  1. update pom.xml for generate code into target/generated-sources so the generated code will not managed via git.
  2. update dapeng-code-generator for some directory bugs.

dapeng-hello's People

Contributors

carterplus avatar struggleyang avatar wangzaixiang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.