first commit
parent
68560b54f6
commit
16488f3c23
Binary file not shown.
@ -0,0 +1,274 @@
|
|||||||
|
# Created by .ignore support plugin (hsz.mobi)
|
||||||
|
### JetBrains template
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/**/dictionaries
|
||||||
|
.idea/**/shelf
|
||||||
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
.idea/**/dbnavigator.xml
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
.idea/**/libraries
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
cmake-build-debug/
|
||||||
|
cmake-build-release/
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
# File-based project format
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
.idea/httpRequests
|
||||||
|
### Java template
|
||||||
|
# Compiled class file
|
||||||
|
*.class
|
||||||
|
|
||||||
|
# Log file
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# BlueJ files
|
||||||
|
*.ctxt
|
||||||
|
|
||||||
|
# Mobile Tools for Java (J2ME)
|
||||||
|
.mtj.tmp/
|
||||||
|
|
||||||
|
# Package Files #
|
||||||
|
*.jar
|
||||||
|
*.war
|
||||||
|
*.nar
|
||||||
|
*.ear
|
||||||
|
*.zip
|
||||||
|
*.tar.gz
|
||||||
|
*.rar
|
||||||
|
|
||||||
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
|
hs_err_pid*
|
||||||
|
### Eclipse template
|
||||||
|
|
||||||
|
.metadata
|
||||||
|
bin/
|
||||||
|
tmp/
|
||||||
|
*.tmp
|
||||||
|
*.bak
|
||||||
|
*.swp
|
||||||
|
*~.nib
|
||||||
|
local.properties
|
||||||
|
.settings/
|
||||||
|
.loadpath
|
||||||
|
.recommenders
|
||||||
|
|
||||||
|
# External tool builders
|
||||||
|
.externalToolBuilders/
|
||||||
|
|
||||||
|
# Locally stored "Eclipse launch configurations"
|
||||||
|
*.launch
|
||||||
|
|
||||||
|
# PyDev specific (Python IDE for Eclipse)
|
||||||
|
*.pydevproject
|
||||||
|
|
||||||
|
# CDT-specific (C/C++ Development Tooling)
|
||||||
|
.cproject
|
||||||
|
|
||||||
|
# CDT- autotools
|
||||||
|
.autotools
|
||||||
|
|
||||||
|
# Java annotation processor (APT)
|
||||||
|
.factorypath
|
||||||
|
|
||||||
|
# PDT-specific (PHP Development Tools)
|
||||||
|
.buildpath
|
||||||
|
|
||||||
|
# sbteclipse plugin
|
||||||
|
.target
|
||||||
|
|
||||||
|
# Tern plugin
|
||||||
|
.tern-project
|
||||||
|
|
||||||
|
# TeXlipse plugin
|
||||||
|
.texlipse
|
||||||
|
|
||||||
|
# STS (Spring Tool Suite)
|
||||||
|
.springBeans
|
||||||
|
|
||||||
|
# Code Recommenders
|
||||||
|
.recommenders/
|
||||||
|
|
||||||
|
# Scala IDE specific (Scala & Java development for Eclipse)
|
||||||
|
.cache-main
|
||||||
|
.scala_dependencies
|
||||||
|
.worksheet
|
||||||
|
|
||||||
|
/.idea/
|
||||||
|
/eureka-server/.mvn/
|
||||||
|
### JetBrains template
|
||||||
|
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
|
||||||
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
# User-specific stuff
|
||||||
|
.idea/**/workspace.xml
|
||||||
|
.idea/**/tasks.xml
|
||||||
|
.idea/**/dictionaries
|
||||||
|
.idea/**/shelf
|
||||||
|
|
||||||
|
# Sensitive or high-churn files
|
||||||
|
.idea/**/dataSources/
|
||||||
|
.idea/**/dataSources.ids
|
||||||
|
.idea/**/dataSources.local.xml
|
||||||
|
.idea/**/sqlDataSources.xml
|
||||||
|
.idea/**/dynamic.xml
|
||||||
|
.idea/**/uiDesigner.xml
|
||||||
|
.idea/**/dbnavigator.xml
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
.idea/**/gradle.xml
|
||||||
|
.idea/**/libraries
|
||||||
|
|
||||||
|
# CMake
|
||||||
|
cmake-build-debug/
|
||||||
|
cmake-build-release/
|
||||||
|
|
||||||
|
# Mongo Explorer plugin
|
||||||
|
.idea/**/mongoSettings.xml
|
||||||
|
|
||||||
|
# File-based project format
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# mpeltonen/sbt-idea plugin
|
||||||
|
.idea_modules/
|
||||||
|
|
||||||
|
# JIRA plugin
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
# Cursive Clojure plugin
|
||||||
|
.idea/replstate.xml
|
||||||
|
|
||||||
|
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||||
|
com_crashlytics_export_strings.xml
|
||||||
|
crashlytics.properties
|
||||||
|
crashlytics-build.properties
|
||||||
|
fabric.properties
|
||||||
|
|
||||||
|
# Editor-based Rest Client
|
||||||
|
.idea/httpRequests
|
||||||
|
### Java template
|
||||||
|
# Compiled class file
|
||||||
|
*.class
|
||||||
|
|
||||||
|
# Log file
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# BlueJ files
|
||||||
|
*.ctxt
|
||||||
|
|
||||||
|
# Mobile Tools for Java (J2ME)
|
||||||
|
.mtj.tmp/
|
||||||
|
|
||||||
|
# Package Files #
|
||||||
|
*.jar
|
||||||
|
*.war
|
||||||
|
*.nar
|
||||||
|
*.ear
|
||||||
|
*.zip
|
||||||
|
*.tar.gz
|
||||||
|
*.rar
|
||||||
|
|
||||||
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
|
hs_err_pid*
|
||||||
|
### Eclipse template
|
||||||
|
|
||||||
|
.metadata
|
||||||
|
bin/
|
||||||
|
tmp/
|
||||||
|
*.tmp
|
||||||
|
*.bak
|
||||||
|
*.swp
|
||||||
|
*~.nib
|
||||||
|
local.properties
|
||||||
|
.settings/
|
||||||
|
.loadpath
|
||||||
|
.recommenders
|
||||||
|
|
||||||
|
# External tool builders
|
||||||
|
.externalToolBuilders/
|
||||||
|
|
||||||
|
# Locally stored "Eclipse launch configurations"
|
||||||
|
*.launch
|
||||||
|
|
||||||
|
# PyDev specific (Python IDE for Eclipse)
|
||||||
|
*.pydevproject
|
||||||
|
|
||||||
|
# CDT-specific (C/C++ Development Tooling)
|
||||||
|
.cproject
|
||||||
|
|
||||||
|
# CDT- autotools
|
||||||
|
.autotools
|
||||||
|
|
||||||
|
# Java annotation processor (APT)
|
||||||
|
.factorypath
|
||||||
|
|
||||||
|
# PDT-specific (PHP Development Tools)
|
||||||
|
.buildpath
|
||||||
|
|
||||||
|
# sbteclipse plugin
|
||||||
|
.target
|
||||||
|
|
||||||
|
# Tern plugin
|
||||||
|
.tern-project
|
||||||
|
|
||||||
|
# TeXlipse plugin
|
||||||
|
.texlipse
|
||||||
|
|
||||||
|
# STS (Spring Tool Suite)
|
||||||
|
.springBeans
|
||||||
|
|
||||||
|
# Code Recommenders
|
||||||
|
.recommenders/
|
||||||
|
|
||||||
|
# Scala IDE specific (Scala & Java development for Eclipse)
|
||||||
|
.cache-main
|
||||||
|
.scala_dependencies
|
||||||
|
.worksheet
|
||||||
|
|
||||||
|
*.cmd
|
||||||
|
*.iml
|
||||||
|
*.mvn
|
||||||
|
*/mvnw
|
||||||
|
*/target
|
||||||
|
|
||||||
|
/logs/
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
HELP.md
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### STS ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
@ -0,0 +1,142 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.5.3</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
<groupId>com.rehome</groupId>
|
||||||
|
<artifactId>admin-client-appmqttserver-yf</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<name>admin-client-appmqttserver-yf</name>
|
||||||
|
<description>admin-client-appmqttserver-yf</description>
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<spring-cloud.version>2020.0.3</spring-cloud.version>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.codecentric</groupId>
|
||||||
|
<artifactId>spring-boot-admin-starter-client</artifactId>
|
||||||
|
<version>2.1.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.paho</groupId>
|
||||||
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
|
<version>1.2.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>2.1.4</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.freemarker</groupId>
|
||||||
|
<artifactId>freemarker</artifactId>
|
||||||
|
<version>2.3.28</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-api</artifactId>
|
||||||
|
<version>2.17.1</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
<version>2.17.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>1.2.47</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-boot-starter</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>swagger-bootstrap-ui</artifactId>
|
||||||
|
<version>1.9.6</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.oracle</groupId>
|
||||||
|
<artifactId>ojdbc6</artifactId>
|
||||||
|
<version>11.2.0.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-dependencies</artifactId>
|
||||||
|
<version>${spring-cloud.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skipTests>true</skipTests>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
@ -0,0 +1,73 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf;
|
||||||
|
|
||||||
|
|
||||||
|
import com.rehome.adminclientappmqttserveryf.controller.UseryfController;
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.boot.CommandLineRunner;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContextAware;
|
||||||
|
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@EnableEurekaClient
|
||||||
|
@EnableJpaAuditing
|
||||||
|
@EnableScheduling
|
||||||
|
public class AdminClientAppmqttserverYfApplication implements CommandLineRunner, ApplicationContextAware {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Spring框架的上下文
|
||||||
|
*/
|
||||||
|
private ApplicationContext applicationContext;
|
||||||
|
/**
|
||||||
|
后台接口自动导入
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private UseryfController userYfController;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(AdminClientAppmqttserverYfApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用 applicationContext(不能在main中使用,main是static的,不能调用)
|
||||||
|
* @param args
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void run(String... args) throws Exception {
|
||||||
|
//在这里可以调用applicationContext了
|
||||||
|
Map<String, Object> controllers = applicationContext.getBeansWithAnnotation(RequestMapping.class);
|
||||||
|
Gson gson = new Gson();
|
||||||
|
// for (Map.Entry<String, Object> entry : controllers.entrySet()) {
|
||||||
|
// System.out.println("------------------------");
|
||||||
|
// System.out.println(entry.getKey());//demo1Controller
|
||||||
|
// }
|
||||||
|
try {
|
||||||
|
if (userYfController != null) {
|
||||||
|
System.out.println("------------------------");
|
||||||
|
System.out.println("UseryfController is not empty");
|
||||||
|
MqttRSAClientYFAPP client_yf = new MqttRSAClientYFAPP();
|
||||||
|
client_yf.start(userYfController);
|
||||||
|
} else {
|
||||||
|
System.out.println("UseryfController is empty");
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
|
this.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,66 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class UserInfo implements Serializable {
|
||||||
|
private String date;
|
||||||
|
|
||||||
|
public String getImeinum() {
|
||||||
|
return imeinum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImeinum(String imeinum) {
|
||||||
|
this.imeinum = imeinum;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String imeinum;
|
||||||
|
private String sysversion;
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
private String phonemodel;
|
||||||
|
|
||||||
|
public String getDate() {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDate(String date) {
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getPhonemodel() {
|
||||||
|
return phonemodel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhonemodel(String phonemodel) {
|
||||||
|
this.phonemodel = phonemodel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSysversion() {
|
||||||
|
return sysversion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSysversion(String sysversion) {
|
||||||
|
this.sysversion = sysversion;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name: SecuritySecureConfig
|
||||||
|
* @desc: 忽略监控端点的跨站伪造请求保护
|
||||||
|
* @author: gxing
|
||||||
|
* @date: 2019-06-04 18:15
|
||||||
|
**/
|
||||||
|
@Configuration
|
||||||
|
public class SecuritySecureConfig extends WebSecurityConfigurerAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
|
http.csrf().ignoringAntMatchers("/actuator/**");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf.config;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
|
import springfox.documentation.builders.PathSelectors;
|
||||||
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
import springfox.documentation.service.ApiInfo;
|
||||||
|
import springfox.documentation.service.Contact;
|
||||||
|
import springfox.documentation.spi.DocumentationType;
|
||||||
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Author : huangwenfei
|
||||||
|
* @ Date : Created in 2021/5/17 9:15 下午
|
||||||
|
* @ Version : $1.0.0.0
|
||||||
|
* @ Description: Swagger3 UI 配置
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class Swagger3Config {
|
||||||
|
@Bean
|
||||||
|
public Docket createRestApi() {
|
||||||
|
return new Docket(DocumentationType.OAS_30)
|
||||||
|
.apiInfo(apiInfo())
|
||||||
|
.select()
|
||||||
|
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||||
|
.paths(PathSelectors.any())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApiInfo apiInfo() {
|
||||||
|
return new ApiInfoBuilder()
|
||||||
|
.title("Swagger3接口文档")
|
||||||
|
.description("更多请咨询服务开发者hwf452")
|
||||||
|
.contact(new Contact("hwf452", "http://www.baidu.com", "hwf452@163.com"))
|
||||||
|
.version("1.0")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.rehome.adminclientappmqttserveryf.entity.Useryf;
|
||||||
|
import com.rehome.adminclientappmqttserveryf.service.UseryfService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author huangwenfei
|
||||||
|
* @since 2022-03-09
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/useryf")
|
||||||
|
public class UseryfController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UseryfService userYfService;
|
||||||
|
|
||||||
|
public void saveUserYF(Useryf user){
|
||||||
|
userYfService.saveByUsernameYF(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.hibernate.annotations.Proxy;
|
||||||
|
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author huangwenfei
|
||||||
|
* @since 2022-03-09
|
||||||
|
*/
|
||||||
|
@EntityListeners(AuditingEntityListener.class)
|
||||||
|
@Proxy(lazy = false)
|
||||||
|
@Data
|
||||||
|
@Entity
|
||||||
|
public class Useryf implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
private String nfc;
|
||||||
|
|
||||||
|
@Column( length = 32)
|
||||||
|
private String date;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf.service;
|
||||||
|
|
||||||
|
import com.rehome.adminclientappmqttserveryf.entity.Useryf;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author huangwenfei
|
||||||
|
* @since 2022-03-09
|
||||||
|
*/
|
||||||
|
public interface UseryfService {
|
||||||
|
public void saveByUsernameYF(Useryf user);
|
||||||
|
}
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf.service.impl;
|
||||||
|
|
||||||
|
import com.rehome.adminclientappmqttserveryf.dao.UseryRepository;
|
||||||
|
import com.rehome.adminclientappmqttserveryf.entity.Useryf;
|
||||||
|
import com.rehome.adminclientappmqttserveryf.service.UseryfService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author huangwenfei
|
||||||
|
* @since 2022-03-09
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Transactional
|
||||||
|
public class UseryfServiceImpl implements UseryfService {
|
||||||
|
@Resource
|
||||||
|
private UseryRepository useryRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveByUsernameYF(Useryf user) {
|
||||||
|
// Useryf useryfDb = this.useryRepository.findByUsername(user.getUsername());
|
||||||
|
// if (useryfDb != null) {
|
||||||
|
// useryfDb.setDate(user.getDate());
|
||||||
|
// useryfDb.setPassword(user.getPassword());
|
||||||
|
// useryfDb.setNfc(user.getNfc());
|
||||||
|
// this.useryRepository.save(useryfDb);
|
||||||
|
// } else {
|
||||||
|
// this.useryRepository.save(user);
|
||||||
|
// }
|
||||||
|
this.useryRepository.save(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,91 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf.utils;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author huangwenfei
|
||||||
|
* @version v1.0.0.0
|
||||||
|
* Created DateTime 2021-04-27 9:35
|
||||||
|
* @description: http请求工具类
|
||||||
|
*/
|
||||||
|
public class HttpURLConnectionUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @date 2021-04-29 11:23
|
||||||
|
* @description: get请求
|
||||||
|
* @Param: urlStr get请求的url
|
||||||
|
*/
|
||||||
|
public static String getNetData(String urlStr) {
|
||||||
|
HttpURLConnection conn = null;
|
||||||
|
|
||||||
|
//连接成功后我们是要读取数据的 所以要有一个输入流
|
||||||
|
InputStream inputStream = null;
|
||||||
|
|
||||||
|
// 因为读取的都是文本信息 所以使用BufferedReader
|
||||||
|
BufferedReader bufferedReader = null;
|
||||||
|
|
||||||
|
//StringBuilder来把接收到的数据拼接起来
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
try {
|
||||||
|
// 读取初始url 并且创建对象
|
||||||
|
URL url = new URL(urlStr);
|
||||||
|
//打开url连接
|
||||||
|
conn = (HttpURLConnection) url.openConnection();
|
||||||
|
//设置连接
|
||||||
|
//请求的方法
|
||||||
|
conn.setRequestMethod("GET");
|
||||||
|
//设置主机连接超时(单位:毫秒)
|
||||||
|
// 发送请求端 连接到 url目标地址端的时间 受距离长短和网络速度的影响
|
||||||
|
conn.setConnectTimeout(15000);
|
||||||
|
//设置从主机读取数据超时(单位:毫秒)
|
||||||
|
// 连接成功后 获取数据的时间 受数据量和服务器处理数据的影响
|
||||||
|
conn.setReadTimeout(60000);
|
||||||
|
|
||||||
|
//设置请求参数 可以指定接收json参数 服务端的key为content-type
|
||||||
|
conn.setRequestProperty("Accept", "application/json");
|
||||||
|
|
||||||
|
//发送请求
|
||||||
|
conn.connect();
|
||||||
|
|
||||||
|
//获取响应码 如果响应码不为200 表示请求不成功
|
||||||
|
if (conn.getResponseCode() != 200) {
|
||||||
|
//todo 此处应该增加异常处理手段
|
||||||
|
return "请求失败!!!";
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取响应码 如果响应码为200 表示请求成功 然后可以读取数据
|
||||||
|
//获取输入流 然后读取数据
|
||||||
|
inputStream = conn.getInputStream();
|
||||||
|
bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
|
||||||
|
|
||||||
|
//逐行读取数据
|
||||||
|
String line;//用来读取数据
|
||||||
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
|
result.append(line);
|
||||||
|
//System.out.print(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
//关闭各种流
|
||||||
|
try {
|
||||||
|
if (bufferedReader != null) {
|
||||||
|
bufferedReader.close();
|
||||||
|
}
|
||||||
|
if (inputStream != null) {
|
||||||
|
inputStream.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf.utils;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author huangwenfei
|
||||||
|
* @version v1.0.0.0
|
||||||
|
* Created DateTime 2021-04-26 9:35
|
||||||
|
* @description: http请求工具类
|
||||||
|
*/
|
||||||
|
public class WeatherUtil {
|
||||||
|
/**
|
||||||
|
* @date 2021-04-29 11:23
|
||||||
|
* @description: get请求
|
||||||
|
* @Param: url get请求的url
|
||||||
|
*/
|
||||||
|
public static String analysisUrl(String url){
|
||||||
|
HttpURLConnection httpConnection = null;
|
||||||
|
String output = "";
|
||||||
|
try {
|
||||||
|
URL targetUrl = new URL(url);
|
||||||
|
httpConnection = (HttpURLConnection) targetUrl.openConnection();
|
||||||
|
httpConnection.setDoOutput(true);
|
||||||
|
httpConnection.setRequestMethod("GET");
|
||||||
|
httpConnection.setRequestProperty("Content-Type",
|
||||||
|
"application/json");
|
||||||
|
InputStreamReader isr = new InputStreamReader(httpConnection
|
||||||
|
.getInputStream(),"utf-8");
|
||||||
|
BufferedReader responseBuffer = new BufferedReader(isr);
|
||||||
|
output = responseBuffer.readLine();
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
httpConnection.disconnect();
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @date 2021-04-29 11:23
|
||||||
|
* @description: get请求
|
||||||
|
* @Param: url get请求的url
|
||||||
|
*/
|
||||||
|
public static String analysisUrlGzip(String url){
|
||||||
|
HttpURLConnection httpConnection = null;
|
||||||
|
String output = "";
|
||||||
|
try {
|
||||||
|
URL targetUrl = new URL(url);
|
||||||
|
httpConnection = (HttpURLConnection) targetUrl.openConnection();
|
||||||
|
httpConnection.setDoOutput(true);
|
||||||
|
httpConnection.setRequestMethod("GET");
|
||||||
|
httpConnection.setRequestProperty("Content-Type", "application/json");
|
||||||
|
InputStream stream = new GZIPInputStream(httpConnection.getInputStream());
|
||||||
|
output = IOUtils.toString(stream,"utf-8");
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
httpConnection.disconnect();
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
class AdminClientAppmqttserverYfApplicationTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void contextLoads() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
HELP.md
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### STS ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
@ -0,0 +1,168 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.5.3</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
<groupId>com.rehome</groupId>
|
||||||
|
<artifactId>admin-client-appmqttserver</artifactId>
|
||||||
|
<version>0.0.1</version>
|
||||||
|
<name>admin-client-appmqttserver</name>
|
||||||
|
<description>Demo project for Spring Boot</description>
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<spring-cloud.version>2020.0.3</spring-cloud.version>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.codecentric</groupId>
|
||||||
|
<artifactId>spring-boot-admin-starter-client</artifactId>
|
||||||
|
<version>2.1.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.paho</groupId>
|
||||||
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
|
<version>1.2.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>2.1.4</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<!-- mybatis plus 代码生成器 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
<version>3.2.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>mybatis-plus-generator</artifactId>
|
||||||
|
<version>3.2.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.freemarker</groupId>
|
||||||
|
<artifactId>freemarker</artifactId>
|
||||||
|
<version>2.3.28</version>
|
||||||
|
</dependency>
|
||||||
|
<!--引入druid数据源-->
|
||||||
|
<!-- https://mvnrepository.com/artifact/com.alibaba/druid -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>druid</artifactId>
|
||||||
|
<version>1.1.21</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-api</artifactId>
|
||||||
|
<version>2.17.1</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
<version>2.17.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>1.2.47</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-cache</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.baomidou</groupId>
|
||||||
|
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
|
||||||
|
<version>3.2.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.springfox</groupId>
|
||||||
|
<artifactId>springfox-boot-starter</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>swagger-bootstrap-ui</artifactId>
|
||||||
|
<version>1.9.6</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.4</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-dependencies</artifactId>
|
||||||
|
<version>${spring-cloud.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skipTests>true</skipTests>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
@ -0,0 +1,69 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver;
|
||||||
|
|
||||||
|
import com.rehome.adminclientappmqttserver.controller.UserController;
|
||||||
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.CommandLineRunner;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContextAware;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@EnableEurekaClient
|
||||||
|
@MapperScan("com.rehome.adminclientappmqttserver.dao")
|
||||||
|
public class AdminClientAppmqttserverApplication implements CommandLineRunner, ApplicationContextAware {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Spring框架的上下文
|
||||||
|
*/
|
||||||
|
private ApplicationContext applicationContext;
|
||||||
|
/**
|
||||||
|
后台接口自动导入
|
||||||
|
*/
|
||||||
|
@Autowired
|
||||||
|
private UserController userController;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(AdminClientAppmqttserverApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用 applicationContext(不能在main中使用,main是static的,不能调用)
|
||||||
|
* @param args
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void run(String... args) throws Exception {
|
||||||
|
//在这里可以调用applicationContext了
|
||||||
|
Map<String, Object> controllers = applicationContext.getBeansWithAnnotation(RequestMapping.class);
|
||||||
|
Gson gson = new Gson();
|
||||||
|
// for (Map.Entry<String, Object> entry : controllers.entrySet()) {
|
||||||
|
// System.out.println("------------------------");
|
||||||
|
// System.out.println(entry.getKey());//demo1Controller
|
||||||
|
// }
|
||||||
|
try {
|
||||||
|
if (userController != null) {
|
||||||
|
System.out.println("------------------------");
|
||||||
|
System.out.println("UserController is not empty");
|
||||||
|
MqttRSAClient client = new MqttRSAClient();
|
||||||
|
client.start(userController);
|
||||||
|
} else {
|
||||||
|
System.out.println("UserController is empty");
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
|
this.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,66 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
public class UserInfo implements Serializable {
|
||||||
|
private String date;
|
||||||
|
|
||||||
|
public String getImeinum() {
|
||||||
|
return imeinum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImeinum(String imeinum) {
|
||||||
|
this.imeinum = imeinum;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String imeinum;
|
||||||
|
private String sysversion;
|
||||||
|
private String username;
|
||||||
|
private String password;
|
||||||
|
private String phonemodel;
|
||||||
|
|
||||||
|
public String getDate() {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDate(String date) {
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String username) {
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPassword() {
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public String getPhonemodel() {
|
||||||
|
return phonemodel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhonemodel(String phonemodel) {
|
||||||
|
this.phonemodel = phonemodel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSysversion() {
|
||||||
|
return sysversion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSysversion(String sysversion) {
|
||||||
|
this.sysversion = sysversion;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver.config;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Author : huangwenfei
|
||||||
|
* @ Date : Created in 2021/5/16 12:11 下午
|
||||||
|
* @ Version : $1.0.0.0
|
||||||
|
* @ Description: 配置分页插件
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class MybatisPlusConfig {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* description: 分页插件
|
||||||
|
* create by: huangwenfei
|
||||||
|
* create time: 2021/5/16 12:11 下午
|
||||||
|
* @Param: null
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Bean
|
||||||
|
public PaginationInterceptor paginationInterceptor() {
|
||||||
|
PaginationInterceptor paginationInterceptor = new PaginationInterceptor();
|
||||||
|
paginationInterceptor.setDialectType("mysql");
|
||||||
|
return paginationInterceptor;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name: SecuritySecureConfig
|
||||||
|
* @desc: 忽略监控端点的跨站伪造请求保护
|
||||||
|
* @author: gxing
|
||||||
|
* @date: 2019-06-04 18:15
|
||||||
|
**/
|
||||||
|
@Configuration
|
||||||
|
public class SecuritySecureConfig extends WebSecurityConfigurerAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
|
http.csrf().ignoringAntMatchers("/actuator/**");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver.config;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import springfox.documentation.builders.ApiInfoBuilder;
|
||||||
|
import springfox.documentation.builders.PathSelectors;
|
||||||
|
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||||
|
import springfox.documentation.service.ApiInfo;
|
||||||
|
import springfox.documentation.service.Contact;
|
||||||
|
import springfox.documentation.spi.DocumentationType;
|
||||||
|
import springfox.documentation.spring.web.plugins.Docket;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Author : huangwenfei
|
||||||
|
* @ Date : Created in 2021/5/17 9:15 下午
|
||||||
|
* @ Version : $1.0.0.0
|
||||||
|
* @ Description: Swagger3 UI 配置
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
public class Swagger3Config {
|
||||||
|
@Bean
|
||||||
|
public Docket createRestApi() {
|
||||||
|
return new Docket(DocumentationType.OAS_30)
|
||||||
|
.apiInfo(apiInfo())
|
||||||
|
.select()
|
||||||
|
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
|
||||||
|
.paths(PathSelectors.any())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApiInfo apiInfo() {
|
||||||
|
return new ApiInfoBuilder()
|
||||||
|
.title("Swagger3接口文档")
|
||||||
|
.description("更多请咨询服务开发者hwf452")
|
||||||
|
.contact(new Contact("hwf452", "http://www.baidu.com", "hwf452@163.com"))
|
||||||
|
.version("1.0")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.rehome.adminclientappmqttserver.entity.User;
|
||||||
|
import com.rehome.adminclientappmqttserver.service.UserService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author huangwenfei
|
||||||
|
* @since 2021-08-17
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/user")
|
||||||
|
public class UserController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
|
||||||
|
public void saveUser(User user){
|
||||||
|
userService.saveByUsername(user);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.rehome.adminclientappmqttserver.entity.User;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author huangwenfei
|
||||||
|
* @since 2021-08-17
|
||||||
|
*/
|
||||||
|
public interface UserMapper extends BaseMapper<User> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,56 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
*
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author huangwenfei
|
||||||
|
* @since 2021-08-17
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@ApiModel(value="User对象", description="")
|
||||||
|
public class User extends Model<User> {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@TableId("username")
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@TableField("password")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@TableField("date")
|
||||||
|
private String date;
|
||||||
|
|
||||||
|
@TableField("imeinum")
|
||||||
|
private String imeinum;
|
||||||
|
|
||||||
|
@TableField("sysversion")
|
||||||
|
private String sysversion;
|
||||||
|
|
||||||
|
@TableField("phonemodel")
|
||||||
|
private String phonemodel;
|
||||||
|
|
||||||
|
@TableField("appversion")
|
||||||
|
private String appversion;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Serializable pkVal() {
|
||||||
|
return this.username;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver.service;
|
||||||
|
|
||||||
|
import com.rehome.adminclientappmqttserver.entity.User;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author huangwenfei
|
||||||
|
* @since 2021-08-17
|
||||||
|
*/
|
||||||
|
public interface UserService extends IService<User> {
|
||||||
|
|
||||||
|
public void saveByUsername(User user);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.rehome.adminclientappmqttserver.entity.User;
|
||||||
|
import com.rehome.adminclientappmqttserver.dao.UserMapper;
|
||||||
|
import com.rehome.adminclientappmqttserver.service.UserService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author huangwenfei
|
||||||
|
* @since 2021-08-17
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveByUsername(User user) {
|
||||||
|
Wrapper<User> wrapper = new QueryWrapper<User>().lambda().eq(User::getUsername, user.getUsername());
|
||||||
|
User userDB = this.getOne(wrapper);
|
||||||
|
if(userDB!=null){
|
||||||
|
this.update(user,wrapper);
|
||||||
|
}else {
|
||||||
|
//数据库不存在这条数据,保存到数据库
|
||||||
|
this.save(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,91 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver.utils;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author huangwenfei
|
||||||
|
* @version v1.0.0.0
|
||||||
|
* Created DateTime 2021-04-27 9:35
|
||||||
|
* @description: http请求工具类
|
||||||
|
*/
|
||||||
|
public class HttpURLConnectionUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @date 2021-04-29 11:23
|
||||||
|
* @description: get请求
|
||||||
|
* @Param: urlStr get请求的url
|
||||||
|
*/
|
||||||
|
public static String getNetData(String urlStr) {
|
||||||
|
HttpURLConnection conn = null;
|
||||||
|
|
||||||
|
//连接成功后我们是要读取数据的 所以要有一个输入流
|
||||||
|
InputStream inputStream = null;
|
||||||
|
|
||||||
|
// 因为读取的都是文本信息 所以使用BufferedReader
|
||||||
|
BufferedReader bufferedReader = null;
|
||||||
|
|
||||||
|
//StringBuilder来把接收到的数据拼接起来
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
try {
|
||||||
|
// 读取初始url 并且创建对象
|
||||||
|
URL url = new URL(urlStr);
|
||||||
|
//打开url连接
|
||||||
|
conn = (HttpURLConnection) url.openConnection();
|
||||||
|
//设置连接
|
||||||
|
//请求的方法
|
||||||
|
conn.setRequestMethod("GET");
|
||||||
|
//设置主机连接超时(单位:毫秒)
|
||||||
|
// 发送请求端 连接到 url目标地址端的时间 受距离长短和网络速度的影响
|
||||||
|
conn.setConnectTimeout(15000);
|
||||||
|
//设置从主机读取数据超时(单位:毫秒)
|
||||||
|
// 连接成功后 获取数据的时间 受数据量和服务器处理数据的影响
|
||||||
|
conn.setReadTimeout(60000);
|
||||||
|
|
||||||
|
//设置请求参数 可以指定接收json参数 服务端的key为content-type
|
||||||
|
conn.setRequestProperty("Accept", "application/json");
|
||||||
|
|
||||||
|
//发送请求
|
||||||
|
conn.connect();
|
||||||
|
|
||||||
|
//获取响应码 如果响应码不为200 表示请求不成功
|
||||||
|
if (conn.getResponseCode() != 200) {
|
||||||
|
//todo 此处应该增加异常处理手段
|
||||||
|
return "请求失败!!!";
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取响应码 如果响应码为200 表示请求成功 然后可以读取数据
|
||||||
|
//获取输入流 然后读取数据
|
||||||
|
inputStream = conn.getInputStream();
|
||||||
|
bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
|
||||||
|
|
||||||
|
//逐行读取数据
|
||||||
|
String line;//用来读取数据
|
||||||
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
|
result.append(line);
|
||||||
|
//System.out.print(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
//关闭各种流
|
||||||
|
try {
|
||||||
|
if (bufferedReader != null) {
|
||||||
|
bufferedReader.close();
|
||||||
|
}
|
||||||
|
if (inputStream != null) {
|
||||||
|
inputStream.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver.utils;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author huangwenfei
|
||||||
|
* @version v1.0.0.0
|
||||||
|
* Created DateTime 2021-04-26 9:35
|
||||||
|
* @description: http请求工具类
|
||||||
|
*/
|
||||||
|
public class WeatherUtil {
|
||||||
|
/**
|
||||||
|
* @date 2021-04-29 11:23
|
||||||
|
* @description: get请求
|
||||||
|
* @Param: url get请求的url
|
||||||
|
*/
|
||||||
|
public static String analysisUrl(String url){
|
||||||
|
HttpURLConnection httpConnection = null;
|
||||||
|
String output = "";
|
||||||
|
try {
|
||||||
|
URL targetUrl = new URL(url);
|
||||||
|
httpConnection = (HttpURLConnection) targetUrl.openConnection();
|
||||||
|
httpConnection.setDoOutput(true);
|
||||||
|
httpConnection.setRequestMethod("GET");
|
||||||
|
httpConnection.setRequestProperty("Content-Type",
|
||||||
|
"application/json");
|
||||||
|
InputStreamReader isr = new InputStreamReader(httpConnection
|
||||||
|
.getInputStream(),"utf-8");
|
||||||
|
BufferedReader responseBuffer = new BufferedReader(isr);
|
||||||
|
output = responseBuffer.readLine();
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
httpConnection.disconnect();
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @date 2021-04-29 11:23
|
||||||
|
* @description: get请求
|
||||||
|
* @Param: url get请求的url
|
||||||
|
*/
|
||||||
|
public static String analysisUrlGzip(String url){
|
||||||
|
HttpURLConnection httpConnection = null;
|
||||||
|
String output = "";
|
||||||
|
try {
|
||||||
|
URL targetUrl = new URL(url);
|
||||||
|
httpConnection = (HttpURLConnection) targetUrl.openConnection();
|
||||||
|
httpConnection.setDoOutput(true);
|
||||||
|
httpConnection.setRequestMethod("GET");
|
||||||
|
httpConnection.setRequestProperty("Content-Type", "application/json");
|
||||||
|
InputStream stream = new GZIPInputStream(httpConnection.getInputStream());
|
||||||
|
output = IOUtils.toString(stream,"utf-8");
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
httpConnection.disconnect();
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.rehome.adminclientappmqttserver.dao.UserMapper">
|
||||||
|
|
||||||
|
<!-- 通用查询映射结果 -->
|
||||||
|
<resultMap id="BaseResultMap" type="com.rehome.adminclientappmqttserver.entity.User">
|
||||||
|
<id column="username" property="username" />
|
||||||
|
<result column="password" property="password" />
|
||||||
|
<result column="date" property="date" />
|
||||||
|
<result column="imeinum" property="imeinum" />
|
||||||
|
<result column="sysversion" property="sysversion" />
|
||||||
|
<result column="phonemodel" property="phonemodel" />
|
||||||
|
<result column="appversion" property="appversion" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 通用查询结果列 -->
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
username, password, date, imeinum, sysversion, phonemodel
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
create table user
|
||||||
|
(
|
||||||
|
username varchar(255) not null,
|
||||||
|
password varchar(255) null,
|
||||||
|
date varchar(255) null,
|
||||||
|
imeinum varchar(50) null,
|
||||||
|
sysversion varchar(100) null,
|
||||||
|
phonemodel varchar(255) null,
|
||||||
|
constraint user_username_uindex
|
||||||
|
unique (username)
|
||||||
|
);
|
||||||
|
|
||||||
|
alter table user
|
||||||
|
add primary key (username);
|
||||||
|
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.rehome.adminclientappmqttserver;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
class AdminClientAppmqttserverApplicationTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void contextLoads() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,33 @@
|
|||||||
|
HELP.md
|
||||||
|
target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
!**/src/main/**/target/
|
||||||
|
!**/src/test/**/target/
|
||||||
|
|
||||||
|
### STS ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
build/
|
||||||
|
!**/src/main/**/build/
|
||||||
|
!**/src/test/**/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
@ -0,0 +1,165 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.5.3</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
<groupId>com.rehome</groupId>
|
||||||
|
<artifactId>admin-client-temperature</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<name>admin-client-temperature</name>
|
||||||
|
<description>aadmin-client-temperature</description>
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<spring-cloud.version>2020.0.3</spring-cloud.version>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mybatis.spring.boot</groupId>
|
||||||
|
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||||
|
<version>2.1.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-java</artifactId>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.codecentric</groupId>
|
||||||
|
<artifactId>spring-boot-admin-starter-client</artifactId>
|
||||||
|
<version>2.1.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.paho</groupId>
|
||||||
|
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||||
|
<version>1.2.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<version>2.8.2</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.squareup.okhttp3</groupId>
|
||||||
|
<artifactId>okhttp</artifactId>
|
||||||
|
<version>3.6.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.9</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains</groupId>
|
||||||
|
<artifactId>annotations</artifactId>
|
||||||
|
<version>19.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.20</version>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-api</artifactId>
|
||||||
|
<version>2.17.1</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
<version>2.17.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.xiaoymin</groupId>
|
||||||
|
<artifactId>swagger-bootstrap-ui</artifactId>
|
||||||
|
<version>1.9.6</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>javax.validation</groupId>
|
||||||
|
<artifactId>validation-api</artifactId>
|
||||||
|
<version>2.0.1.Final</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.oracle</groupId>
|
||||||
|
<artifactId>ojdbc6</artifactId>
|
||||||
|
<version>11.2.0.1.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-annotations</artifactId>
|
||||||
|
<version>1.5.20</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>1.2.47</version>
|
||||||
|
</dependency>
|
||||||
|
<!--sqlserver驱动 -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.microsoft.sqlserver</groupId>
|
||||||
|
<artifactId>mssql-jdbc</artifactId>
|
||||||
|
<version>11.2.0.jre8</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-dependencies</artifactId>
|
||||||
|
<version>${spring-cloud.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
<build>
|
||||||
|
<finalName>${project.artifactId}</finalName>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<skipTests>true</skipTests>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
@ -0,0 +1,69 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf;
|
||||||
|
|
||||||
|
|
||||||
|
import com.rehome.adminclientappmqttserveryf.service.TemperatureService;
|
||||||
|
import org.springframework.beans.BeansException;
|
||||||
|
import org.springframework.boot.CommandLineRunner;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationContextAware;
|
||||||
|
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||||
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
@EnableJpaAuditing
|
||||||
|
@EnableScheduling
|
||||||
|
@SpringBootApplication
|
||||||
|
@EnableEurekaClient
|
||||||
|
public class AdminClientTemperatureApplication implements CommandLineRunner, ApplicationContextAware {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取Spring框架的上下文
|
||||||
|
*/
|
||||||
|
private ApplicationContext applicationContext;
|
||||||
|
/**
|
||||||
|
后台接口自动导入
|
||||||
|
*/
|
||||||
|
@Resource
|
||||||
|
private TemperatureService temperatureService;
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(AdminClientTemperatureApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用 applicationContext(不能在main中使用,main是static的,不能调用)
|
||||||
|
* @param args
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void run(String... args) throws Exception {
|
||||||
|
//在这里可以调用applicationContext了
|
||||||
|
Map<String, Object> controllers = applicationContext.getBeansWithAnnotation(RequestMapping.class);
|
||||||
|
for (Map.Entry<String, Object> entry : controllers.entrySet()) {
|
||||||
|
System.out.println("------------------------");
|
||||||
|
System.out.println(entry.getKey());//demo1Controller
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (temperatureService != null) {
|
||||||
|
System.out.println("------------------------");
|
||||||
|
System.out.println("UseryfController is not empty");
|
||||||
|
MqttRSAClient client = new MqttRSAClient();
|
||||||
|
client.start(temperatureService);
|
||||||
|
} else {
|
||||||
|
System.out.println("UseryfController is empty");
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
|
this.applicationContext = applicationContext;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf.controller;
|
||||||
|
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ Author : huangwenfei
|
||||||
|
* @ Date : Created in 2023/1/31 10:09 下午
|
||||||
|
* @ Version : $1.0.0.0
|
||||||
|
* @ Description:
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
public class MainController {
|
||||||
|
@GetMapping(value = "/main/echo")
|
||||||
|
public String echo(){
|
||||||
|
return "hello world";
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,52 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf.entity;
|
||||||
|
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.hibernate.annotations.Proxy;
|
||||||
|
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@EntityListeners(AuditingEntityListener.class)
|
||||||
|
@Proxy(lazy = false)
|
||||||
|
@Data
|
||||||
|
@Entity
|
||||||
|
public class Temperature implements Serializable {
|
||||||
|
@Id
|
||||||
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "温度")
|
||||||
|
private Double temperature;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "湿度")
|
||||||
|
private Double humidity;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "日期")
|
||||||
|
@Column(length=20)
|
||||||
|
private String dataDate;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "时")
|
||||||
|
@Column(length=20)
|
||||||
|
private String dataHour;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "分")
|
||||||
|
@Column(length=20)
|
||||||
|
private String dataMinute;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "主题")
|
||||||
|
@Column(length=60)
|
||||||
|
private String topic;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "位置描述")
|
||||||
|
@Column(length=80)
|
||||||
|
private String locationDesc;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "时间")
|
||||||
|
@Temporal(TemporalType.TIMESTAMP)
|
||||||
|
private Date createDate;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf.service;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author huangwenfei
|
||||||
|
* @version v1.0.0.0
|
||||||
|
* Created DateTime 2021-04-26 14:35
|
||||||
|
* @description: 定时任务服务
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class ScheduledService {
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf.service;
|
||||||
|
|
||||||
|
public interface TemperatureService {
|
||||||
|
//温度和湿度
|
||||||
|
void saveTemperature(String temperatureAndHumidityData,String topic);
|
||||||
|
}
|
||||||
@ -0,0 +1,53 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf.service.impl;
|
||||||
|
|
||||||
|
import com.rehome.adminclientappmqttserveryf.dao.TemperatureRepository;
|
||||||
|
import com.rehome.adminclientappmqttserveryf.entity.Temperature;
|
||||||
|
import com.rehome.adminclientappmqttserveryf.service.TemperatureService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TemperatureServiceImpl implements TemperatureService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private TemperatureRepository temperatureRepository;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveTemperature(String temperatureAndHumidityData,String topic) {
|
||||||
|
if(temperatureAndHumidityData!=null&&temperatureAndHumidityData.length()>0){
|
||||||
|
String[] strDataTemperature = temperatureAndHumidityData.split(" ");
|
||||||
|
Date now = new Date();
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
|
SimpleDateFormat sdfHour = new SimpleDateFormat("yyyy-MM-dd HH");
|
||||||
|
SimpleDateFormat sdfMinute = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
||||||
|
|
||||||
|
String nowDate = sdf.format(now);
|
||||||
|
String nowHour = sdfHour.format(now);
|
||||||
|
String dataMinute = sdfMinute.format(now);
|
||||||
|
Temperature temperature = new Temperature();
|
||||||
|
temperature.setCreateDate(now);
|
||||||
|
temperature.setDataDate(nowDate);
|
||||||
|
temperature.setDataHour(nowHour);
|
||||||
|
temperature.setDataMinute(dataMinute);
|
||||||
|
if(topic!=null){
|
||||||
|
temperature.setTopic(topic);
|
||||||
|
if(topic.equals("WifiSHT/7C87CE9CA4E6/SHT20")){
|
||||||
|
temperature.setLocationDesc("广东省珠海市高新区唐家湾镇东岸村水风三街28号501");
|
||||||
|
}
|
||||||
|
if(topic.equals("WifiSHT/7C87CE9F5CBF/SHT20")){
|
||||||
|
temperature.setLocationDesc("广东省中山市坦洲镇金斗新村7号东座602");
|
||||||
|
}
|
||||||
|
if(topic.equals("WifiSHT/4CEBD686B6AA/SHT20")){
|
||||||
|
temperature.setLocationDesc("广西壮族自治区崇左市天等县天等镇荣华村弄在屯113号");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
temperature.setHumidity(Double.valueOf(strDataTemperature[0]));
|
||||||
|
temperature.setTemperature(Double.valueOf(strDataTemperature[1]));
|
||||||
|
|
||||||
|
this.temperatureRepository.save(temperature);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,91 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf.utils;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author huangwenfei
|
||||||
|
* @version v1.0.0.0
|
||||||
|
* Created DateTime 2021-04-27 9:35
|
||||||
|
* @description: http请求工具类
|
||||||
|
*/
|
||||||
|
public class HttpURLConnectionUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @date 2021-04-29 11:23
|
||||||
|
* @description: get请求
|
||||||
|
* @Param: urlStr get请求的url
|
||||||
|
*/
|
||||||
|
public static String getNetData(String urlStr) {
|
||||||
|
HttpURLConnection conn = null;
|
||||||
|
|
||||||
|
//连接成功后我们是要读取数据的 所以要有一个输入流
|
||||||
|
InputStream inputStream = null;
|
||||||
|
|
||||||
|
// 因为读取的都是文本信息 所以使用BufferedReader
|
||||||
|
BufferedReader bufferedReader = null;
|
||||||
|
|
||||||
|
//StringBuilder来把接收到的数据拼接起来
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
try {
|
||||||
|
// 读取初始url 并且创建对象
|
||||||
|
URL url = new URL(urlStr);
|
||||||
|
//打开url连接
|
||||||
|
conn = (HttpURLConnection) url.openConnection();
|
||||||
|
//设置连接
|
||||||
|
//请求的方法
|
||||||
|
conn.setRequestMethod("GET");
|
||||||
|
//设置主机连接超时(单位:毫秒)
|
||||||
|
// 发送请求端 连接到 url目标地址端的时间 受距离长短和网络速度的影响
|
||||||
|
conn.setConnectTimeout(15000);
|
||||||
|
//设置从主机读取数据超时(单位:毫秒)
|
||||||
|
// 连接成功后 获取数据的时间 受数据量和服务器处理数据的影响
|
||||||
|
conn.setReadTimeout(60000);
|
||||||
|
|
||||||
|
//设置请求参数 可以指定接收json参数 服务端的key为content-type
|
||||||
|
conn.setRequestProperty("Accept", "application/json");
|
||||||
|
|
||||||
|
//发送请求
|
||||||
|
conn.connect();
|
||||||
|
|
||||||
|
//获取响应码 如果响应码不为200 表示请求不成功
|
||||||
|
if (conn.getResponseCode() != 200) {
|
||||||
|
//todo 此处应该增加异常处理手段
|
||||||
|
return "请求失败!!!";
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取响应码 如果响应码为200 表示请求成功 然后可以读取数据
|
||||||
|
//获取输入流 然后读取数据
|
||||||
|
inputStream = conn.getInputStream();
|
||||||
|
bufferedReader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
|
||||||
|
|
||||||
|
//逐行读取数据
|
||||||
|
String line;//用来读取数据
|
||||||
|
while ((line = bufferedReader.readLine()) != null) {
|
||||||
|
result.append(line);
|
||||||
|
//System.out.print(line);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} finally {
|
||||||
|
//关闭各种流
|
||||||
|
try {
|
||||||
|
if (bufferedReader != null) {
|
||||||
|
bufferedReader.close();
|
||||||
|
}
|
||||||
|
if (inputStream != null) {
|
||||||
|
inputStream.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,90 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf.utils;
|
||||||
|
|
||||||
|
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||||
|
import org.bouncycastle.openssl.PEMKeyPair;
|
||||||
|
import org.bouncycastle.openssl.PEMParser;
|
||||||
|
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
|
||||||
|
|
||||||
|
import javax.net.ssl.KeyManagerFactory;
|
||||||
|
import javax.net.ssl.SSLContext;
|
||||||
|
import javax.net.ssl.SSLSocketFactory;
|
||||||
|
import javax.net.ssl.TrustManagerFactory;
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.security.KeyPair;
|
||||||
|
import java.security.KeyStore;
|
||||||
|
import java.security.Security;
|
||||||
|
import java.security.cert.CertificateFactory;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
|
||||||
|
public class MqttSSLSocketFactory {
|
||||||
|
public static SSLSocketFactory getSingleSocketFactory(InputStream caCrtFileInputStream) throws Exception {
|
||||||
|
Security.addProvider(new BouncyCastleProvider());
|
||||||
|
X509Certificate caCert = null;
|
||||||
|
|
||||||
|
BufferedInputStream bis = new BufferedInputStream(caCrtFileInputStream);
|
||||||
|
CertificateFactory cf = CertificateFactory.getInstance("X.509");
|
||||||
|
|
||||||
|
while (bis.available() > 0) {
|
||||||
|
caCert = (X509Certificate) cf.generateCertificate(bis);
|
||||||
|
}
|
||||||
|
KeyStore caKs = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||||
|
caKs.load(null, null);
|
||||||
|
caKs.setCertificateEntry("cert-certificate", caCert);
|
||||||
|
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||||
|
tmf.init(caKs);
|
||||||
|
SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
|
||||||
|
sslContext.init(null, tmf.getTrustManagers(), null);
|
||||||
|
return sslContext.getSocketFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SSLSocketFactory getTwoDirSocketFactory(InputStream caCrtFile, InputStream crtFile, InputStream keyFile,
|
||||||
|
String password) throws Exception {
|
||||||
|
Security.addProvider(new BouncyCastleProvider());
|
||||||
|
|
||||||
|
// load CA certificate
|
||||||
|
X509Certificate caCert = null;
|
||||||
|
|
||||||
|
BufferedInputStream bis = new BufferedInputStream(caCrtFile);
|
||||||
|
CertificateFactory cf = CertificateFactory.getInstance("X.509");
|
||||||
|
|
||||||
|
while (bis.available() > 0) {
|
||||||
|
caCert = (X509Certificate) cf.generateCertificate(bis);
|
||||||
|
}
|
||||||
|
|
||||||
|
// load client certificate
|
||||||
|
bis = new BufferedInputStream(crtFile);
|
||||||
|
X509Certificate cert = null;
|
||||||
|
while (bis.available() > 0) {
|
||||||
|
cert = (X509Certificate) cf.generateCertificate(bis);
|
||||||
|
}
|
||||||
|
|
||||||
|
// load client private cert
|
||||||
|
PEMParser pemParser = new PEMParser(new InputStreamReader(keyFile));
|
||||||
|
Object object = pemParser.readObject();
|
||||||
|
JcaPEMKeyConverter converter = new JcaPEMKeyConverter();
|
||||||
|
KeyPair key = converter.getKeyPair((PEMKeyPair) object);
|
||||||
|
|
||||||
|
KeyStore caKs = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||||
|
caKs.load(null, null);
|
||||||
|
caKs.setCertificateEntry("cert-certificate", caCert);
|
||||||
|
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
|
||||||
|
tmf.init(caKs);
|
||||||
|
|
||||||
|
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
|
||||||
|
ks.load(null, null);
|
||||||
|
ks.setCertificateEntry("certificate", cert);
|
||||||
|
ks.setKeyEntry("private-cert", key.getPrivate(), password.toCharArray(),
|
||||||
|
new java.security.cert.Certificate[]{cert});
|
||||||
|
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
|
||||||
|
kmf.init(ks, password.toCharArray());
|
||||||
|
|
||||||
|
SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
|
||||||
|
sslContext.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
|
||||||
|
|
||||||
|
return sslContext.getSocketFactory();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf.utils;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class UUIDUtil {
|
||||||
|
public static String getUUID() {
|
||||||
|
return UUID.randomUUID().toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf.utils;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author huangwenfei
|
||||||
|
* @version v1.0.0.0
|
||||||
|
* Created DateTime 2021-04-26 9:35
|
||||||
|
* @description: http请求工具类
|
||||||
|
*/
|
||||||
|
public class WeatherUtil {
|
||||||
|
/**
|
||||||
|
* @date 2021-04-29 11:23
|
||||||
|
* @description: get请求
|
||||||
|
* @Param: url get请求的url
|
||||||
|
*/
|
||||||
|
public static String analysisUrl(String url){
|
||||||
|
HttpURLConnection httpConnection = null;
|
||||||
|
String output = "";
|
||||||
|
try {
|
||||||
|
URL targetUrl = new URL(url);
|
||||||
|
httpConnection = (HttpURLConnection) targetUrl.openConnection();
|
||||||
|
httpConnection.setDoOutput(true);
|
||||||
|
httpConnection.setRequestMethod("GET");
|
||||||
|
httpConnection.setRequestProperty("Content-Type",
|
||||||
|
"application/json");
|
||||||
|
InputStreamReader isr = new InputStreamReader(httpConnection
|
||||||
|
.getInputStream(),"utf-8");
|
||||||
|
BufferedReader responseBuffer = new BufferedReader(isr);
|
||||||
|
output = responseBuffer.readLine();
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
httpConnection.disconnect();
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @date 2021-04-29 11:23
|
||||||
|
* @description: get请求
|
||||||
|
* @Param: url get请求的url
|
||||||
|
*/
|
||||||
|
public static String analysisUrlGzip(String url){
|
||||||
|
HttpURLConnection httpConnection = null;
|
||||||
|
String output = "";
|
||||||
|
try {
|
||||||
|
URL targetUrl = new URL(url);
|
||||||
|
httpConnection = (HttpURLConnection) targetUrl.openConnection();
|
||||||
|
httpConnection.setDoOutput(true);
|
||||||
|
httpConnection.setRequestMethod("GET");
|
||||||
|
httpConnection.setRequestProperty("Content-Type", "application/json");
|
||||||
|
InputStream stream = new GZIPInputStream(httpConnection.getInputStream());
|
||||||
|
output = IOUtils.toString(stream,"utf-8");
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
httpConnection.disconnect();
|
||||||
|
}
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
@ -0,0 +1,27 @@
|
|||||||
|
-----BEGIN RSA PRIVATE KEY-----
|
||||||
|
MIIEpAIBAAKCAQEA4omYWBuiZ2bPhpmZFuvX50FMP07k/rI4uajLT1irRwoUn0ZR
|
||||||
|
xLO+voWb+0pMnLH6Aq/ehBW+WVOn4eQ4BBpSNXm4n5tJo71+FKKMk0uaX7NnBJ+P
|
||||||
|
FJxJxoBn5kFNAXUWdDojCTVMBX3k/QG679n6bYzzguk5Ky/pIEvePleox49MJJ5W
|
||||||
|
C3fHWNMODhWEYJXGgxjCSmWynLPmEdOyi2/KfKfplgCx1NYPbPW1JtZSRjJ9zK6b
|
||||||
|
5g2uGts50JEDuWAkYXpztAetaBF68+h79aHKP78AAHRa+0cT+4J1uxwcf9XK7fQt
|
||||||
|
5UGkuDZpUVWjQ9a44ciwaAXcKy9hqYRfSm9GBQIDAQABAoIBAQDCVBxOgK4pG2Ws
|
||||||
|
ZjiQFBJqe3ZH3IrN/d5xTV3SnBKZZwlXtD/SiAp5by3mO89Kn9YC1hEAp5JZGE0s
|
||||||
|
ltSCmH2rB9abe9+IybXNR79lX3Z23/PgYGuh14vl7yKxv5SqSmHPpEuHy6OCFoQH
|
||||||
|
kaNlu0x7C22dACodZQULwmlMe2/6dtHQbs9x0OROnJa9SpnScXfaPW/g/ONqR7S1
|
||||||
|
rytHsM8dWUSEvNCUBqGqUFCTBPX44+w1RBLji36ZP1zeenlcBSMGlBifVJKH5OCk
|
||||||
|
MFR33iwh3BXxIi+he+DGBX8c1CRplgfitQZlSnX5I0OXcBm1r0I9zrC2hs1w4WVd
|
||||||
|
KNpr556FAoGBAPxqeqp7UaVfSQOMLQrpFAEBP6sqYd9dM3S81COpEB0i1i/6eZiE
|
||||||
|
dPiP92OXp5Ka3/0pT0h66K+enkmKQ788OaGtJpz6KIU25ZRN+t+tS4UslFg67BY5
|
||||||
|
bdFad2pIF2Ql89EzqCmzHz6q2xc0SD467jEPS4FcNf8G91lJvamuLYkvAoGBAOXB
|
||||||
|
DIP8FiF3jn0DaoQpv3sX4R9UKNXOcaJmaprVZ5VHml8vrszrKju2HogKtyEzCMiS
|
||||||
|
I+MBSg9Vum5n9MFHUd/eRAqV1oh3l2QsR0AEJe230xXotoZ8Vdid32JNtsnR7YRL
|
||||||
|
q/OcMFhdpk50J8cVlx3gnC61S54jl1pAEFWSMW8LAoGATjZkKf0qMFbVFe9SaaYN
|
||||||
|
F76eTthEGWUUs6BrD12sa4rG2XkAQn0QjZB2dHqiZu/sZdJuCaRkAz7gByN7mH79
|
||||||
|
0JYJd+yfr59yBcEf8j0NQIeus6QWUVCcMZmZlOofrV2BLhqWic1B6jYgyxDdLcMu
|
||||||
|
2S7HE59R7+Lls9oAldotq+sCgYEAhd6IFldJ5dItufXFmKBiq6xsRb7Z1Epnt8KJ
|
||||||
|
FxKFOlvwPMohxdC4WPZyr73emn+L/KH6OwjDSFAhQrdby0ptEE4Hw0svJ3DXS0zp
|
||||||
|
bwl7uBlF6xwfThkgRAko4bR6bvnctRsKY/V7zeEzR78ydjPES2pWVnjYSJpgU/vE
|
||||||
|
CLgYCaUCgYBzgGR2IrTfGdu9TVkEt9dAYS2QKwI+iEpTBLdJBCPiXbfg1Jh8xH5t
|
||||||
|
vmFOYQPnvyu6cRg9JQFXAVmEHcjC0VPwy/wURxVcgw1il/zmUrUAERVhpG/4uC4N
|
||||||
|
XQK0ipg/gvSEJKyiqeQN+nLv0PrdQ9vCQSG9sSMvWHL6dTcQDeNDiw==
|
||||||
|
-----END RSA PRIVATE KEY-----
|
||||||
Binary file not shown.
@ -0,0 +1,13 @@
|
|||||||
|
package com.rehome.adminclientappmqttserveryf;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
class AdminClientAppmqttserverYfApplicationTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void contextLoads() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
HELP.md
|
||||||
|
/target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
|
||||||
|
### STS ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
Binary file not shown.
@ -0,0 +1,82 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" 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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.1.5.RELEASE</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
<groupId>com.springcloud.adminclient</groupId>
|
||||||
|
<artifactId>admin-client</artifactId>
|
||||||
|
<version>0.0.1</version>
|
||||||
|
<name>admin-client</name>
|
||||||
|
<description>Demo project for Spring Boot</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.codecentric</groupId>
|
||||||
|
<artifactId>spring-boot-admin-starter-client</artifactId>
|
||||||
|
<version>2.1.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-api</artifactId>
|
||||||
|
<version>2.17.1</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-core -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
<version>2.17.1</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-dependencies</artifactId>
|
||||||
|
<version>${spring-cloud.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.springcloud.adminclient;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class AdminClientApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(AdminClientApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.springcloud.adminclient.config;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name: SecuritySecureConfig
|
||||||
|
* @desc: 忽略监控端点的跨站伪造请求保护
|
||||||
|
* @author: gxing
|
||||||
|
* @date: 2019-06-04 18:15
|
||||||
|
**/
|
||||||
|
@Configuration
|
||||||
|
public class SecuritySecureConfig extends WebSecurityConfigurerAdapter {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
|
http.csrf().ignoringAntMatchers("/actuator/**");
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,23 @@
|
|||||||
|
package com.springcloud.adminclient.controller;
|
||||||
|
|
||||||
|
import com.springcloud.adminclient.entity.Student;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name: StudentController
|
||||||
|
* @desc: TODO
|
||||||
|
* @author: gxing
|
||||||
|
* @date: 2019-06-05 16:07
|
||||||
|
**/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/stu")
|
||||||
|
public class StudentController {
|
||||||
|
|
||||||
|
@RequestMapping("/getStudent")
|
||||||
|
public Student getStudent(){
|
||||||
|
return new Student(12,new Date());
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
package com.springcloud.adminclient.entity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name: Student
|
||||||
|
* @desc: TODO
|
||||||
|
* @author: gxing
|
||||||
|
* @date: 2019-06-05 16:06
|
||||||
|
**/
|
||||||
|
public class Student {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Date birthday;
|
||||||
|
|
||||||
|
public Student() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Student(Integer id, Date birthday) {
|
||||||
|
this.id = id;
|
||||||
|
this.birthday = birthday;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Student setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getBirthday() {
|
||||||
|
return birthday;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Student setBirthday(Date birthday) {
|
||||||
|
this.birthday = birthday;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.springcloud.adminclient;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
public class AdminClientApplicationTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void contextLoads() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
HELP.md
|
||||||
|
/target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
|
||||||
|
### STS ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
@ -0,0 +1,84 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" 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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.1.5.RELEASE</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
<groupId>com.springcloud.adminserver</groupId>
|
||||||
|
<artifactId>admin-server</artifactId>
|
||||||
|
<version>0.0.1</version>
|
||||||
|
<name>admin-server</name>
|
||||||
|
<description>Demo project for Spring Boot</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>de.codecentric</groupId>
|
||||||
|
<artifactId>spring-boot-admin-starter-server</artifactId>
|
||||||
|
<version>2.1.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!--<dependency>
|
||||||
|
<groupId>com.hazelcast</groupId>
|
||||||
|
<artifactId>hazelcast</artifactId>
|
||||||
|
</dependency>-->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-core</artifactId>
|
||||||
|
<version>2.17.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.logging.log4j</groupId>
|
||||||
|
<artifactId>log4j-api</artifactId>
|
||||||
|
<version>2.17.1</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-dependencies</artifactId>
|
||||||
|
<version>${spring-cloud.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
package com.springcloud.adminserver;
|
||||||
|
|
||||||
|
import de.codecentric.boot.admin.server.config.EnableAdminServer;
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@EnableAdminServer
|
||||||
|
public class AdminServerApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(AdminServerApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
package com.springcloud.adminserver.config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name: HazelcastConfig
|
||||||
|
* @desc: TODO
|
||||||
|
* @author: gxing
|
||||||
|
* @date: 2019-06-05 10:02
|
||||||
|
**/
|
||||||
|
/*
|
||||||
|
@Configuration
|
||||||
|
public class HazelcastConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Config hazelcastConfig() {
|
||||||
|
MapConfig mapConfig = new MapConfig("spring-boot-admin-event-store").setInMemoryFormat(InMemoryFormat.OBJECT)
|
||||||
|
.setBackupCount(1)
|
||||||
|
.setEvictionPolicy(EvictionPolicy.NONE)
|
||||||
|
.setMergePolicyConfig(new MergePolicyConfig(PutIfAbsentMapMergePolicy.class.getName(), 100));
|
||||||
|
return new Config().setProperty("hazelcast.jmx", "true").addMapConfig(mapConfig);
|
||||||
|
}
|
||||||
|
}*/
|
||||||
@ -0,0 +1,55 @@
|
|||||||
|
package com.springcloud.adminserver.config;
|
||||||
|
|
||||||
|
import de.codecentric.boot.admin.server.config.AdminServerProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||||
|
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||||
|
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
|
||||||
|
import org.springframework.security.web.csrf.CookieCsrfTokenRepository;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name: SecuritySecureConfig
|
||||||
|
* @desc: TODO
|
||||||
|
* @author: gxing
|
||||||
|
* @date: 2019-06-04 17:17
|
||||||
|
**/
|
||||||
|
@Configuration
|
||||||
|
public class SecuritySecureConfig extends WebSecurityConfigurerAdapter {
|
||||||
|
|
||||||
|
private final String adminContextPath;
|
||||||
|
|
||||||
|
public SecuritySecureConfig(AdminServerProperties adminServerProperties) {
|
||||||
|
this.adminContextPath = adminServerProperties.getContextPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void configure(HttpSecurity http) throws Exception {
|
||||||
|
// @formatter:off
|
||||||
|
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
|
||||||
|
successHandler.setTargetUrlParameter("redirectTo");
|
||||||
|
successHandler.setDefaultTargetUrl(adminContextPath + "/");
|
||||||
|
|
||||||
|
http.authorizeRequests()
|
||||||
|
//放行静态资源
|
||||||
|
.antMatchers(adminContextPath + "/assets/**").permitAll()
|
||||||
|
.antMatchers(adminContextPath + "/login").permitAll()
|
||||||
|
//对每个请求认证
|
||||||
|
.anyRequest().authenticated()
|
||||||
|
.and()
|
||||||
|
//登录和注销
|
||||||
|
.formLogin().loginPage(adminContextPath + "/login").successHandler(successHandler).and()
|
||||||
|
.logout().logoutUrl(adminContextPath + "/logout").and()
|
||||||
|
//启用HTTP-Basic支持。Spring Boot Admin Client注册必需的。
|
||||||
|
.httpBasic().and()
|
||||||
|
.csrf()
|
||||||
|
//使用Cookie启用CSRF保护
|
||||||
|
.csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse())
|
||||||
|
.ignoringAntMatchers(
|
||||||
|
//禁用CRSF-Protection Spring Boot Admin Client用于注册的端点。
|
||||||
|
adminContextPath + "/instances",
|
||||||
|
//禁用执行器端点的CRSF保护。
|
||||||
|
adminContextPath + "/actuator/**"
|
||||||
|
);
|
||||||
|
// @formatter:on
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
server.port=9070
|
||||||
|
spring.application.name=admin-server
|
||||||
|
eureka.environment=prod
|
||||||
|
eureka.instance.hostname=192.168.1.5
|
||||||
|
eureka.client.service-url.defaultZone=http://admin:123456@eureka.master.com:8761/eureka,http://admin:123456@eureka.slave.com:8762/eureka
|
||||||
|
|
||||||
|
spring.security.user.name=user
|
||||||
|
spring.security.user.password=123456
|
||||||
|
|
||||||
|
eureka.instance.metadata-map.user.name=${spring.security.user.name}
|
||||||
|
eureka.instance.metadata-map.user.password=${spring.security.user.password}
|
||||||
|
eureka.instance.health-check-url-path=/actuator/health
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.springcloud.adminserver;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
public class SpringbootAdminApplicationTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void contextLoads() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
HELP.md
|
||||||
|
/target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
|
||||||
|
### STS ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
@ -0,0 +1,86 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" 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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.1.5.RELEASE</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
<groupId>com.springcloud.commons</groupId>
|
||||||
|
<artifactId>commons-jar</artifactId>
|
||||||
|
<version>0.0.1</version>
|
||||||
|
<name>commons-jar</name>
|
||||||
|
<description>Demo project for Spring Boot</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!--java-jwt-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.auth0</groupId>
|
||||||
|
<artifactId>java-jwt</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>1.2.56</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.hutool</groupId>
|
||||||
|
<artifactId>hutool-all</artifactId>
|
||||||
|
<version>4.5.10</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-lang</groupId>
|
||||||
|
<artifactId>commons-lang</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.9</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-beanutils</groupId>
|
||||||
|
<artifactId>commons-beanutils</artifactId>
|
||||||
|
<version>1.9.3</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>27.0.1-jre</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpclient</artifactId>
|
||||||
|
<version>4.5.8</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.springcloud.commons;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
public class CommonsJarApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(CommonsJarApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
package com.springcloud.commons.bean;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name: JwtToken
|
||||||
|
* @desc: JWT 实体
|
||||||
|
* @author: gxing
|
||||||
|
* @date: 2019-05-30 14:00
|
||||||
|
**/
|
||||||
|
public class JwtToken implements Serializable {
|
||||||
|
private static final long serialVersionUID = 7780238154438192887L;
|
||||||
|
|
||||||
|
private String jwtId;
|
||||||
|
private String token;
|
||||||
|
|
||||||
|
public JwtToken() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public JwtToken(String jwtId, String token) {
|
||||||
|
this.jwtId = jwtId;
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getJwtId() {
|
||||||
|
return jwtId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JwtToken setJwtId(String jwtId) {
|
||||||
|
this.jwtId = jwtId;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToken() {
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JwtToken setToken(String token) {
|
||||||
|
this.token = token;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,20 @@
|
|||||||
|
package com.springcloud.commons.bean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name: ResponseCode
|
||||||
|
* @desc: TODO
|
||||||
|
* @author: gxing
|
||||||
|
* @date: 2019-05-27 11:43
|
||||||
|
**/
|
||||||
|
public class ResponseCode {
|
||||||
|
|
||||||
|
/*成功/正确 编码*/
|
||||||
|
public static final int SUCCESS_CODE = 200;
|
||||||
|
|
||||||
|
/*失败/错误 编码*/
|
||||||
|
public static final int TOKEN_TIME_OUT = 401;
|
||||||
|
public static final int NO_AUTO = 402;
|
||||||
|
public static final int SIGN_ERROR = 402;
|
||||||
|
public static final int PARAM_IS_NULL = 403;
|
||||||
|
public static final int PARAM_IS_ERROR = 404;
|
||||||
|
}
|
||||||
@ -0,0 +1,94 @@
|
|||||||
|
package com.springcloud.commons.bean;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name: ResultBean
|
||||||
|
* @desc: TODO
|
||||||
|
* @author: gxing
|
||||||
|
* @date: 2019-05-27 14:06
|
||||||
|
**/
|
||||||
|
public class ResultBean implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -1936178861383421225L;
|
||||||
|
|
||||||
|
private static final String STATE_SUCCESS = "success";
|
||||||
|
private static final String STATE_FAIL = "fail";
|
||||||
|
private static final Integer CODE_SUCCESS = 200;
|
||||||
|
private static final Integer CODE_FAIL = 400;
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
private String state;
|
||||||
|
private String msg;
|
||||||
|
private Object date;
|
||||||
|
|
||||||
|
public ResultBean() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultBean(String state, Integer code, String msg, Object date) {
|
||||||
|
this.state = state;
|
||||||
|
this.code = code;
|
||||||
|
this.msg = msg;
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultBean success() {
|
||||||
|
this.state = STATE_SUCCESS;
|
||||||
|
this.code = CODE_SUCCESS;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultBean fial() {
|
||||||
|
this.state = STATE_FAIL;
|
||||||
|
this.code = CODE_FAIL;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultBean fialByNullParam() {
|
||||||
|
this.state = STATE_FAIL;
|
||||||
|
this.code = ResponseCode.PARAM_IS_NULL;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultBean fialByErrorParam() {
|
||||||
|
this.state = STATE_FAIL;
|
||||||
|
this.code = ResponseCode.PARAM_IS_ERROR;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getState() {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultBean setState(String state) {
|
||||||
|
this.state = state;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultBean setCode(Integer code) {
|
||||||
|
this.code = code;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsg() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultBean setMsg(String msg) {
|
||||||
|
this.msg = msg;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getDate() {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ResultBean setDate(Object date) {
|
||||||
|
this.date = date;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,161 @@
|
|||||||
|
package com.springcloud.commons.util;
|
||||||
|
|
||||||
|
import com.auth0.jwt.JWT;
|
||||||
|
import com.auth0.jwt.JWTVerifier;
|
||||||
|
import com.auth0.jwt.algorithms.Algorithm;
|
||||||
|
import com.auth0.jwt.exceptions.JWTVerificationException;
|
||||||
|
|
||||||
|
import java.security.interfaces.RSAPrivateKey;
|
||||||
|
import java.security.interfaces.RSAPublicKey;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name: JavaJwtUtil
|
||||||
|
* @desc: java_jwt 库工具类,签发验证token
|
||||||
|
* @author: gxing
|
||||||
|
* @date: 2019-05-27 11:11
|
||||||
|
**/
|
||||||
|
public class JavaJwtUtil {
|
||||||
|
|
||||||
|
/*默认有效期 1天 = 24小时*/
|
||||||
|
private static final Long END_DATETIME = System.currentTimeMillis() + 1000 * 60 * 1440;
|
||||||
|
private static RSAPrivateKey rsaPrivateKey = RSAUtil.getPrivateKey(RSAUtil.MODULUS, RSAUtil.PRIVATE_EXPONENT);
|
||||||
|
private static RSAPublicKey rsaPublicKey = RSAUtil.getPublicKey(RSAUtil.MODULUS, RSAUtil.PUBLIC_EXPONENT);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HMAC256 算法签发Token
|
||||||
|
*
|
||||||
|
* @param jwtId 用户id
|
||||||
|
* @param secret 密钥
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public static String getTokenByHMAC256(String jwtId, String secret) {
|
||||||
|
String token = JWT.create()
|
||||||
|
.withClaim("jwtId", jwtId)
|
||||||
|
.withExpiresAt(new Date(END_DATETIME))
|
||||||
|
.sign(Algorithm.HMAC256(secret));
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HMAC256 算法签发Token
|
||||||
|
*
|
||||||
|
* @param jwtId 用户id
|
||||||
|
* @param exp 过期时间,单位:分钟
|
||||||
|
* @param secret 密钥
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public static String getTokenByHMAC256(String jwtId, int exp, String secret) {
|
||||||
|
Long endDateTime = System.currentTimeMillis() + 1000 * 60 * exp;
|
||||||
|
|
||||||
|
String token = JWT.create()
|
||||||
|
.withClaim("jwtId", jwtId)
|
||||||
|
.withExpiresAt(new Date(endDateTime))
|
||||||
|
.sign(Algorithm.HMAC256(secret));
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RSA512 算法签发Token
|
||||||
|
*
|
||||||
|
* @param jwtId 用户ID
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public static String getTokenByRSA512(String jwtId) {
|
||||||
|
Algorithm algorithm = Algorithm.RSA512(rsaPublicKey, rsaPrivateKey);
|
||||||
|
String token = JWT.create()
|
||||||
|
.withClaim("jwtId", jwtId)
|
||||||
|
.withExpiresAt(new Date(END_DATETIME))
|
||||||
|
.sign(algorithm);
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RSA512 算法签发Token
|
||||||
|
*
|
||||||
|
* @param jwtId 用户id
|
||||||
|
* @param exp 有效期
|
||||||
|
* @return String
|
||||||
|
*/
|
||||||
|
public static String getTokenByRSA512(String jwtId, int exp) {
|
||||||
|
|
||||||
|
Long endDateTime = System.currentTimeMillis() + 1000 * 60 * exp;
|
||||||
|
|
||||||
|
Algorithm algorithm = Algorithm.RSA512(rsaPublicKey, rsaPrivateKey);
|
||||||
|
String token = JWT.create()
|
||||||
|
.withClaim("jwtId", jwtId)
|
||||||
|
.withExpiresAt(new Date(endDateTime))
|
||||||
|
.sign(algorithm);
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证 HMAC256 Token
|
||||||
|
*
|
||||||
|
* @param token 令牌
|
||||||
|
* @param jwtId 用户id
|
||||||
|
* @param secret 密钥
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static boolean verifyTokenByHMAC256(String token, String jwtId, String secret) {
|
||||||
|
|
||||||
|
JWTVerifier jwtVerifier = JWT.require(Algorithm.HMAC256(secret))
|
||||||
|
.withClaim("jwtId", jwtId).build();
|
||||||
|
return verifyToken(token, jwtVerifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证 RSA512 Token
|
||||||
|
*
|
||||||
|
* @param token 令牌
|
||||||
|
* @param jwtId 用户ID
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public static boolean verifyTokenByRSA512(String token, String jwtId) {
|
||||||
|
|
||||||
|
JWTVerifier jwtVerifier = JWT.require(Algorithm.RSA512(rsaPublicKey, rsaPrivateKey))
|
||||||
|
.withClaim("jwtId", jwtId).build();
|
||||||
|
return verifyToken(token, jwtVerifier);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证 Token
|
||||||
|
*
|
||||||
|
* @param token 令牌
|
||||||
|
* @param jwtVerifier JWTVerifier对象
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
private static boolean verifyToken(String token, JWTVerifier jwtVerifier) {
|
||||||
|
try {
|
||||||
|
jwtVerifier.verify(token);
|
||||||
|
return true;
|
||||||
|
} catch (JWTVerificationException e) {
|
||||||
|
throw e;
|
||||||
|
// return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
public static void main(String[] args) {
|
||||||
|
|
||||||
|
String token1 = JavaJwtUtil.getTokenByHMAC256("1001", 60, "AABBCCDD");
|
||||||
|
System.out.println(token1);
|
||||||
|
|
||||||
|
String token2 = JavaJwtUtil.getTokenByHMAC256("1001", "aabbccdd");
|
||||||
|
System.out.println(token2);
|
||||||
|
|
||||||
|
boolean check = JavaJwtUtil.verifyTokenByHMAC256(token2, "1001", "aabbccdd");
|
||||||
|
System.out.println(check);
|
||||||
|
|
||||||
|
String tokenByRSA = JavaJwtUtil.getTokenByRSA512("1001");
|
||||||
|
String tokenByRSA = JavaJwtUtil.getTokenByRSA512("1001", 1);
|
||||||
|
|
||||||
|
System.out.println(tokenByRSA);
|
||||||
|
|
||||||
|
boolean check = JavaJwtUtil.verifyTokenByRSA512(tokenByRSA, "1001");
|
||||||
|
System.out.println(check);
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
@ -0,0 +1 @@
|
|||||||
|
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.springcloud.commons;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
public class CommonsJarApplicationTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void contextLoads() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
HELP.md
|
||||||
|
/target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
|
||||||
|
### STS ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
@ -0,0 +1,86 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" 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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-parent</artifactId>
|
||||||
|
<version>2.1.4.RELEASE</version>
|
||||||
|
<relativePath/> <!-- lookup parent from repository -->
|
||||||
|
</parent>
|
||||||
|
<groupId>com.springcloud.configserver</groupId>
|
||||||
|
<artifactId>config-server-git</artifactId>
|
||||||
|
<version>v1.0.0</version>
|
||||||
|
<name>config-server-git</name>
|
||||||
|
<description>Demo project for Spring Boot</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<spring-cloud.version>Greenwich.RELEASE</spring-cloud.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<!--<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
</dependency>-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-config-server</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-bus-amqp</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba</groupId>
|
||||||
|
<artifactId>fastjson</artifactId>
|
||||||
|
<version>1.2.47</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-dependencies</artifactId>
|
||||||
|
<version>${spring-cloud.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.springcloud.configserver;
|
||||||
|
|
||||||
|
import org.springframework.boot.SpringApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.cloud.config.server.ConfigServerApplication;
|
||||||
|
import org.springframework.cloud.config.server.EnableConfigServer;
|
||||||
|
|
||||||
|
@SpringBootApplication
|
||||||
|
@EnableConfigServer
|
||||||
|
public class ConfigServerGitApplication {
|
||||||
|
|
||||||
|
public static void main(String[] args) {
|
||||||
|
SpringApplication.run(ConfigServerGitApplication.class, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package com.springcloud.configserver.controller;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name: PropertyController
|
||||||
|
* @desc: TODO
|
||||||
|
* @author: gxing
|
||||||
|
* @date: 2019-04-10 18:27
|
||||||
|
**/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/property")
|
||||||
|
public class PropertyController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Environment environment;
|
||||||
|
|
||||||
|
@GetMapping("/url")
|
||||||
|
public String getUrl(){
|
||||||
|
String gitUrl = environment.getProperty("spring.cloud.config.server.git.uri");
|
||||||
|
|
||||||
|
return gitUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,26 @@
|
|||||||
|
# 端口
|
||||||
|
server.port=9010
|
||||||
|
#spring.profiles.active=git
|
||||||
|
# 应用名
|
||||||
|
spring.application.name=config-repo
|
||||||
|
# 注册到 Eureka
|
||||||
|
eureka.client.service-url.defaultZone=http://admin:123456@eureka.master.com:8761/eureka,http://admin:123456@eureka.slave.com:8762/eureka
|
||||||
|
# Git URI 使用占位符
|
||||||
|
spring.cloud.config.server.git.uri=https://github.com/gxing19/config-repo
|
||||||
|
#spring.cloud.config.server.git.uri=https://github.com/gxing19/${spring.application.name}
|
||||||
|
|
||||||
|
# 设置 HTTP 连接超时时长, 单位:秒
|
||||||
|
spring.cloud.config.server.git.timeout=10
|
||||||
|
# foce-pull 默认 false
|
||||||
|
spring.cloud.config.server.git.force-pull=true
|
||||||
|
# 删除本地未跟踪的库
|
||||||
|
spring.cloud.config.server.git.delete-untracked-branches=true
|
||||||
|
|
||||||
|
# Rabbitmq
|
||||||
|
spring.rabbitmq.host=10.0.3.6
|
||||||
|
spring.rabbitmq.port=5672
|
||||||
|
spring.rabbitmq.username=configServer
|
||||||
|
spring.rabbitmq.password=123456
|
||||||
|
management.endpoints.web.exposure.include=bus-refresh,bus-env
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,77 @@
|
|||||||
|
#端口
|
||||||
|
server.port=9010
|
||||||
|
#应用名
|
||||||
|
#spring.application.name=configServer
|
||||||
|
spring.application.name=config-repo
|
||||||
|
#eureka 注册中心地址
|
||||||
|
#eureka.client.service-url.defaultZone=http://eureka.master.com:8761/eureka,http://eureka.slave.com:8762/eureka
|
||||||
|
eureka.client.service-url.defaultZone=http://admin:123456@eureka.master.com:8761/eureka,http://admin:123456@eureka.slave.com:8762/eureka
|
||||||
|
|
||||||
|
|
||||||
|
# 配置管理仓库
|
||||||
|
#spring.cloud.config.server.git.uri=https://github.com/spring-cloud-samples/config-repo
|
||||||
|
|
||||||
|
# Git URI 使用占位符
|
||||||
|
spring.cloud.config.server.git.uri=https://github.com/spring-cloud-samples/${spring.application.name}
|
||||||
|
|
||||||
|
|
||||||
|
# 模式匹配
|
||||||
|
#spring.cloud.config.server.git.uri=https://github.com/spring-cloud-samples/config-repo
|
||||||
|
#spring.cloud.config.server.git.repos.simple=https://github.com/simple/config-repo
|
||||||
|
#spring.cloud.config.server.git.repos.special.pattern=special*/dev*,*special*/dev*
|
||||||
|
#spring.cloud.config.server.git.repos.special.uri=https://github.com/special/config-repo
|
||||||
|
#spring.cloud.config.server.git.repos.local.pattern=local*
|
||||||
|
#spring.cloud.config.server.git.repos.local.uri=file:/home/configsvc/config-repo
|
||||||
|
|
||||||
|
# 使用数组匹配多个配置文件
|
||||||
|
#spring.cloud.config.server.git.uri=https://github.com/spring-cloud-samples/config-repo
|
||||||
|
#spring.cloud.config.server.git.repos.development.pattern[0]=*/development
|
||||||
|
#spring.cloud.config.server.git.repos.development.pattern[1]=*/staging
|
||||||
|
#spring.cloud.config.server.git.repos.development.uri=https://github.com/development/config-repo
|
||||||
|
#spring.cloud.config.server.git.repos.staging.pattern[0]=*/qa
|
||||||
|
#spring.cloud.config.server.git.repos.staging.pattern[1]=*/production
|
||||||
|
#spring.cloud.config.server.git.repos.staging.uri=https://github.com/staging/config-repo
|
||||||
|
|
||||||
|
# 指定首次请求是否克隆存储库
|
||||||
|
#spring.cloud.config.server.git.uri=https://git/common/config-repo.git
|
||||||
|
#spring.cloud.config.server.git.repos.team-a.pattern=team-a-*
|
||||||
|
#spring.cloud.config.server.git.repos.team-a.clone-on-start=true
|
||||||
|
#spring.cloud.config.server.git.repos.team-a.uri=http://git/team-a/config-repo.git
|
||||||
|
#spring.cloud.config.server.git.repos.team-b.pattern=team-b-*
|
||||||
|
#spring.cloud.config.server.git.repos.team-b.clone-on-start=false
|
||||||
|
#spring.cloud.config.server.git.repos.team-b.uri=http://git/team-b/config-repo.git
|
||||||
|
#spring.cloud.config.server.git.repos.team-c.pattern=team-c-*
|
||||||
|
#spring.cloud.config.server.git.repos.team-c.uri=http://git/team-a/config-repo.git
|
||||||
|
|
||||||
|
# Git 认证
|
||||||
|
#spring.cloud.config.server.git.uri=https://github.com/spring-cloud-samples/config-repo
|
||||||
|
#spring.cloud.config.server.git.username=trolley
|
||||||
|
#spring.cloud.config.server.git.password=strongPassword
|
||||||
|
#spring.cloud.config.server.git.force-pull=true
|
||||||
|
#spring.cloud.config.server.git.delete-untracked-branches=true
|
||||||
|
#spring.cloud.config.server.git.refresh-rate=5
|
||||||
|
|
||||||
|
|
||||||
|
# 配置存储在子目录中
|
||||||
|
#spring.cloud.config.server.git.search-paths=foo,bar*
|
||||||
|
|
||||||
|
# 禁用配置服务器对 Git服务器的SSL证书的验证
|
||||||
|
spring.cloud.config.server.git.skip-ssl-validation=true
|
||||||
|
|
||||||
|
# 设置 HTTP 连接超时时长, 单位:秒
|
||||||
|
spring.cloud.config.server.git.timeout=10
|
||||||
|
#spring.config.name=configServer
|
||||||
|
#logging.level.root=debug
|
||||||
|
|
||||||
|
# 配置属性覆盖
|
||||||
|
#spring.cloud.config.server.overrides.foo=bar
|
||||||
|
|
||||||
|
# 健康指标器
|
||||||
|
#spring.cloud.config.server.health.repositories.myservice.label=mylabel
|
||||||
|
#spring.cloud.config.server.health.repositories.myservice-dev.name=myservice
|
||||||
|
#spring.cloud.config.server.health.repositories.myservice-dev.profiles=development
|
||||||
|
|
||||||
|
# Spring Security 账号密码
|
||||||
|
#spring.security.user.name=admin
|
||||||
|
spring.security.user.password=strong_password
|
||||||
|
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
package com.springcloud.configserver;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.junit4.SpringRunner;
|
||||||
|
|
||||||
|
@RunWith(SpringRunner.class)
|
||||||
|
@SpringBootTest
|
||||||
|
public class ConfigServerApplicationTests {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void contextLoads() {
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
HELP.md
|
||||||
|
/target/
|
||||||
|
!.mvn/wrapper/maven-wrapper.jar
|
||||||
|
|
||||||
|
### STS ###
|
||||||
|
.apt_generated
|
||||||
|
.classpath
|
||||||
|
.factorypath
|
||||||
|
.project
|
||||||
|
.settings
|
||||||
|
.springBeans
|
||||||
|
.sts4-cache
|
||||||
|
|
||||||
|
### IntelliJ IDEA ###
|
||||||
|
.idea
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
|
||||||
|
### NetBeans ###
|
||||||
|
/nbproject/private/
|
||||||
|
/nbbuild/
|
||||||
|
/dist/
|
||||||
|
/nbdist/
|
||||||
|
/.nb-gradle/
|
||||||
|
/build/
|
||||||
|
|
||||||
|
### VS Code ###
|
||||||
|
.vscode/
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue