org.noear:water.client-springboot-starter

Java project for water

License

License

Categories

Categories

CLI User Interface
GroupId

GroupId

org.noear
ArtifactId

ArtifactId

water.client-springboot-starter
Last Version

Last Version

2.0.20
Release Date

Release Date

Type

Type

jar
Description

Description

Java project for water

Download water.client-springboot-starter

How to add to project

<!-- https://jarcasting.com/artifacts/org.noear/water.client-springboot-starter/ -->
<dependency>
    <groupId>org.noear</groupId>
    <artifactId>water.client-springboot-starter</artifactId>
    <version>2.0.20</version>
</dependency>
// https://jarcasting.com/artifacts/org.noear/water.client-springboot-starter/
implementation 'org.noear:water.client-springboot-starter:2.0.20'
// https://jarcasting.com/artifacts/org.noear/water.client-springboot-starter/
implementation ("org.noear:water.client-springboot-starter:2.0.20")
'org.noear:water.client-springboot-starter:jar:2.0.20'
<dependency org="org.noear" name="water.client-springboot-starter" rev="2.0.20">
  <artifact name="water.client-springboot-starter" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.noear', module='water.client-springboot-starter', version='2.0.20')
)
libraryDependencies += "org.noear" % "water.client-springboot-starter" % "2.0.20"
[org.noear/water.client-springboot-starter "2.0.20"]

Dependencies

compile (2)

Group / Artifact Type Version
org.noear : water.client-solon-plugin jar 2.0.20
org.noear : solon-springboot-starter jar 1.3.10

provided (1)

Group / Artifact Type Version
org.springframework.boot : spring-boot-autoconfigure jar 2.0.4.RELEASE

Project Modules

There are no modules declared in this project.

Maven Central

QQ交流群:22200020

Water for java (水孕育万物...)

为中小量级项目,提供服务开发和治理的整体解决方案(可以理解为微服务架构套件)。

开始

了解框架与构件

组件 说明
org.noear:water.client 框架:Water 客户端
org.noear:water-solon-plugin 框架:Water 客户端 for solon
org.noear:waterapi 构建:Water 服务端
org.noear:watersev 构建:Water 后台服务(消息派发;定时任务;服务检测...)
org.noear:wateradmin 构建:Water 控制台
org.noear:waterpaas 构建:Water PaaS 服务,提供轻量级接口服务
org.noear:waterraas 构建:Water RaaS 服务,提供轻量级规则计算服务

(一) 使用

配置

  • pom.xml / mevan 配置
<!-- 暂时没有 springboot starter 版本 -->
<dependency>
    <groupId>org.noear</groupId>
    <artifactId>water-solon-plugin</artifactId>
    <version>1.3.14</version>
</dependency>
  • application.yml / 配置说明
solon.app:
  name: "wateradmin"
  group: "water"

solon.cloud.water:
  server: water                     #WATER服务地址
  config:
    loadKey: "test.properties"      #默认加载的配置
  event:
    hostname: "api.water.io"        #当前服务主机地址(一般设为外网地址;用于订阅业务消息用)
    #hostname: "@water_admin_host"  #如果域名会变,可通过配置指定(@开头,表示从water配置服务获取)
  log:
    default: "water_log_admin"      #默认日志记录器

代码

public class DemoApp{
  public void main(String[] args){
      Solon app = Solon.start(args);

      //监控服务:之:添加接口性能记录
      app.before("**",XMethod.HTTP,-1,(c)->{
          c.attrSet("_timecount", new Timecount().start());
      });
      app.after("**", XMethod.HTTP,(c)->{
          Timecount timecount = c.attr("_timecount", null);
  
          if (timecount == null || c.status() == 404) {
              return;
          }
  
          String node = WaterAdapter.global().localHost();
          long times = timecount.stop().milliseconds();
  
          WaterClient.Track.track("water-demo", "path", c.path(), times, node);
      });
  }
}

@Slf4j
@Controller
class demo{
    @CloudConfig("water")  //配置服务的功能(注解模式)
    DbContext waterDb;

    @NamiClient            //RPC服务发现的功能(注解模式)
    RockRpc rock;
   
    @Mapping("/")
    public void test(){
        //日志服务:写个日志
        log.info("你好,日志服务"); //(content)
        TagsMDC.tag0("demo");
        log.error("{}\r\n{}","test","你好,日志服务"); //(tag,summary,content)
        
        //配置服务:使用配置的数据库上下文进行查询
        var map = waterDb.table("bcf_user").limit(1).select("*").getMap();

        //消息服务:发送消息
        CloudClient.event().publish(new Event("test.order.start", "{\"order_id\":1}")); //(非注解模式)
    
        //PaaS服务:调用PaaS接口
        WaterProxy.paas("water/test", null);

        //Rpc发现服务:调用Rpc接口
        AppModel app = rock.getAppById(12);
    }
}

//消息订阅:订阅消息并处理(根据:topic 进行订阅)
@CloudEvent("test.order.end")
public class msg_updatecache implements CloudEventHandler {
    @Override
    public boolean handler(Event event) throws Exception {
        //处理消息...
    }
}

//配置订阅:关注配置的实时更新
@CloudConfig("water")
public class TestConfigHandler implements CloudConfigHandler {
    @Override
    public void handler(Config config) {

    }
}

(二)演示代码

https://gitee.com/noear/water_demo

(三)部署

相关材料未准备好...

(四)架构说明

相关材料未准备好...

管理界面预览

  • 报警专用客户端

  • 管理小工具

  • 日志查询

  • 消息中心管理

  • 服务监控

  • 配置管理

  • PaaS管理后台

  • 开发者小工具

Versions

Version
2.0.20
2.0.19
2.0.18
2.0.17
2.0.16
2.0.15
2.0.14
2.0.13
2.0.12
2.0.10
2.0.9
2.0.8
2.0.7.1
2.0.7
2.0.6