usrcloud-spring-boot-autoconfigure

usrcloud integration with springboot.

License

License

Categories

Categories

Spring Boot Container Microservices Auto Application Layer Libs Code Generators config Configuration
GroupId

GroupId

com.cuisongliu
ArtifactId

ArtifactId

usrcloud-spring-boot-autoconfigure
Last Version

Last Version

1.4.1
Release Date

Release Date

Type

Type

jar
Description

Description

usrcloud-spring-boot-autoconfigure
usrcloud integration with springboot.
Project URL

Project URL

https://github.com/cuisongliu/usrcloud-boot-starter
Source Code Management

Source Code Management

https://github.com/cuisongliu/usrcloud-boot-starter

Download usrcloud-spring-boot-autoconfigure

How to add to project

<!-- https://jarcasting.com/artifacts/com.cuisongliu/usrcloud-spring-boot-autoconfigure/ -->
<dependency>
    <groupId>com.cuisongliu</groupId>
    <artifactId>usrcloud-spring-boot-autoconfigure</artifactId>
    <version>1.4.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.cuisongliu/usrcloud-spring-boot-autoconfigure/
implementation 'com.cuisongliu:usrcloud-spring-boot-autoconfigure:1.4.1'
// https://jarcasting.com/artifacts/com.cuisongliu/usrcloud-spring-boot-autoconfigure/
implementation ("com.cuisongliu:usrcloud-spring-boot-autoconfigure:1.4.1")
'com.cuisongliu:usrcloud-spring-boot-autoconfigure:jar:1.4.1'
<dependency org="com.cuisongliu" name="usrcloud-spring-boot-autoconfigure" rev="1.4.1">
  <artifact name="usrcloud-spring-boot-autoconfigure" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.cuisongliu', module='usrcloud-spring-boot-autoconfigure', version='1.4.1')
)
libraryDependencies += "com.cuisongliu" % "usrcloud-spring-boot-autoconfigure" % "1.4.1"
[com.cuisongliu/usrcloud-spring-boot-autoconfigure "1.4.1"]

Dependencies

compile (4)

Group / Artifact Type Version
org.eclipse.paho : org.eclipse.paho.client.mqttv3 jar 1.2.0
org.apache.httpcomponents : httpclient jar 4.5.3
org.apache.commons : commons-io jar 1.3.2
com.alibaba : fastjson jar 1.2.41

Project Modules

There are no modules declared in this project.

license license

Usrcloud integration with springboot

Usrcloud-Spring-Boot-Starter 帮助你集成通用 Usrcloud 到 Spring Boot。

How to use

maven

在pom.xml加入nexus资源库(解决中国访问慢的问题,已经加入中央仓库)

Add the following nexus repository(fix china access slow problem,already append to central nexus.) to your pom.xml:

<repositories>
    <repository>
        <id>nexus</id>
        <name>nexus</name>
        <url>http://maven.cuisongliu.com/content/groups/public</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

在pom.xml加入依赖

Add the following dependency to your pom.xml:

<dependency>
   <groupId>com.cuisongliu</groupId>
   <artifactId>usrcloud-spring-boot-starter</artifactId>
   <version>1.4.2</version>
 </dependency>

gradle

在build.gradle加入nexus资源库(解决中国访问慢的问题,已经加入中央仓库)

Add the following nexus repository(fix china access slow problem,already append to central nexus.) to your build.gradle:

allprojects {
    repositories {
        mavenLocal()
        maven { url "http://maven.cuisongliu.com/content/groups/public" }
        mavenCentral()
        jcenter()
    }
}

在build.gradle加入依赖

Add the following dependency to your build.gradle:

compile "com.cuisongliu:usrcloud-spring-boot-starter:1+"

spring Autowired Bean (by type)

UsrcloudApi UsrcloudMqttClient 接口已经实现 你可以直接使用在被spring管理的Bean中

UsrcloudApi UsrcloudMqttClient already implement , you can used in the spring bean.

   @Autowired
   private UsrcloudApi usrcloudApi; 
   @Autowired
   private UsrcloudMqttClient usrcloudMqttClient;

但是UsrcloudMqttCallback回调函数需要自己实现接口,因为这个是个回调函数需要经过RTU返回指令后进行业务操作. However, the UsrcloudMqttCallback callback function needs to implement its own interface, because this is a callback function to perform business operations after the RTU return instruction.

  /**
   * 有人云回调函数 只能一个
   *
   * @author cuisongliu [[email protected]]
   * @since 2018-03-10 21:17
   */
  @Service
  public class UsrCloudCallback implements UsrCloudMqttCallback {
        @Override
        public void onConnectAck(int returnCode, String description) {
        }
    
        @Override
        public void onSubscribeAck(int messageId, String clientId, String topics, int returnCode) {
        }
    
        @Override
        public void onDisSubscribeAck(int messageId, String clientId, String topics, int returnCode) {
        }
    
        @Override
        public void onReceiveEvent(int messageId, String topic, byte[] data) {
        }
    
        @Override
        public void onReceiveParsedEvent(int messageId, String topic, String jsonData) {
        }
    
        @Override
        public void onPublishDataAck(int messageId, String topic, boolean isSuccess) {
        }
    
        @Override
        public void onPublishDataResult(int messageId, String topic) {
        }
  }

springboot properties set

在application.properties 或者application.yml设置用户信息

at application.properties or application.yml append your account message.

properties IsNull? Defaults
spring.usrcloud.account no null
spring.usrcloud.password no null
spring.usrcloud.timeout yes 20
spring.usrcloud.keepAlive yes 600
spring.usrcloud.maxInflight yes 10

Example

spring:
   usrcloud:
       account: cuisongliu
       password: xxxxxx

Acknowledgments

usrcloud.

Versions

Version
1.4.1
1.4
1.3
1.2
1.1