Commit b9436832 authored by hubin's avatar hubin

增加一个简易自动脚本

parent 78baaeee
......@@ -10,9 +10,9 @@ spring:
nacos:
discovery:
server-addr: qw.hungraim.com:31158
namespace: 87d6f6f1-6583-46ea-ad02-7e8125f03c90
namespace: 0e0f834a-a665-4d27-ae04-9d53c2e02140
config:
namespace: 87d6f6f1-6583-46ea-ad02-7e8125f03c90
namespace: 0e0f834a-a665-4d27-ae04-9d53c2e02140
server-addr: qw.hungraim.com:31158
file-extension: yaml # 必须修改成yaml
extension-configs:
......
......@@ -10,9 +10,9 @@ spring:
nacos:
discovery:
server-addr: qw.hungraim.com:31158
namespace: 87d6f6f1-6583-46ea-ad02-7e8125f03c90
namespace: 0e0f834a-a665-4d27-ae04-9d53c2e02140
config:
namespace: 87d6f6f1-6583-46ea-ad02-7e8125f03c90
namespace: 0e0f834a-a665-4d27-ae04-9d53c2e02140
server-addr: qw.hungraim.com:31158
file-extension: yaml # 必须修改成yaml
extension-configs:
......
......@@ -10,9 +10,9 @@ spring:
nacos:
discovery:
server-addr: qw.hungraim.com:31158
namespace: 87d6f6f1-6583-46ea-ad02-7e8125f03c90
namespace: 0e0f834a-a665-4d27-ae04-9d53c2e02140
config:
namespace: 87d6f6f1-6583-46ea-ad02-7e8125f03c90
namespace: 0e0f834a-a665-4d27-ae04-9d53c2e02140
server-addr: qw.hungraim.com:31158
file-extension: yaml # 必须修改成yaml
extension-configs:
......
......@@ -2,13 +2,14 @@
<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">
<parent>
<artifactId>common</artifactId>
<groupId>com.hungraim.ltc</groupId>
<version>0.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>common-core</artifactId>
<parent>
<artifactId>common</artifactId>
<groupId>com.hungraim.ltc</groupId>
<version>0.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>common-core</artifactId>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
......@@ -23,52 +24,52 @@
</build>
<dependencies>
<dependency>
<groupId>com.hungraim.ltc</groupId>
<artifactId>common-redis</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
<dependency>
<groupId>com.hungraim.ltc</groupId>
<artifactId>common-redis</artifactId>
<version>0.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-jose</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-oauth2-jose</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
</dependencies>
</dependencies>
<distributionManagement>
<repository>
<id>releases</id>
<name>Nexus Release Repository</name>
<url>http://121.5.28.27:9091/nexus/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://121.5.28.27:9091/nexus/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<distributionManagement>
<repository>
<id>releases</id>
<name>Nexus Release Repository</name>
<url>http://121.5.28.27:9091/nexus/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://121.5.28.27:9091/nexus/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
package com.hungraim.ltc.util;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.hungraim.ltc.constant.AuthConstants;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpHead;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.apache.logging.log4j.util.Strings;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import sun.misc.BASE64Decoder;
import javax.servlet.http.HttpServletRequest;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.Objects;
/**
* @author hubin
*/
@Slf4j
public class RequestUtils {
public static HttpServletRequest getRequest() {
return ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
}
public static JSONObject getJwtPayload() {
String jwtPayload = getRequest().getHeader(AuthConstants.JWT_PAYLOAD_KEY);
return JSONUtil.parseObj(jwtPayload);
}
@SneakyThrows
public static String getAuthClientId() {
String clientId;
HttpServletRequest request = getRequest();
// 从请求路径中获取
clientId = request.getParameter(AuthConstants.CLIENT_ID_KEY);
if (StrUtil.isNotBlank(clientId)) {
return clientId;
}
// 从请求头获取
String basic = request.getHeader(AuthConstants.AUTHORIZATION_KEY);
if (StrUtil.isNotBlank(basic) && basic.startsWith(AuthConstants.BASIC_PREFIX)) {
basic = basic.replace(AuthConstants.BASIC_PREFIX, Strings.EMPTY);
String basicPlainText = new String(new BASE64Decoder().decodeBuffer(basic), StandardCharsets.UTF_8);
//client:secret
clientId = basicPlainText.split(":")[0];
}
return clientId;
}
/**
* 发起http post请求
*
* @param url 请求地址
* @param entity 请求参数
* @return 返回信息,出错返回空
*/
@SneakyThrows
public static String post(String url, JSONObject entity, Map<String, String> header) {
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = null;
try {
HttpPost httpPost = new HttpPost(url);
HttpHead httpHead = new HttpHead();
//设置head
if (header != null) {
header.forEach(httpHead::setHeader);
}
StringEntity se = new StringEntity(entity.toString(), "UTF-8");
se.setContentType("application/json");
httpPost.setEntity(se);
response = httpClient.execute(httpPost);
HttpEntity entity1 = response.getEntity();
String resStr = null;
if (entity1 != null) {
resStr = EntityUtils.toString(entity1, StandardCharsets.UTF_8);
}
httpClient.close();
response.close();
return resStr;
} catch (Exception e) {
log.error("POST请求:{},出现错误:{}", url, e.getMessage());
e.printStackTrace();
} finally {
if (httpClient != null) {
httpClient.close();
}
if (response != null) {
response.close();
}
}
return "";
}
/**
* 发起http get请求
*
* @param url 请求地址
* @return 返回信息,出错返回空
*/
@SneakyThrows
public static String get(String url) {
CloseableHttpClient httpClient = HttpClients.createDefault();
CloseableHttpResponse response = null;
try {
HttpGet httpGet = new HttpGet(url);
response = httpClient.execute(httpGet);
HttpEntity entity1 = response.getEntity();
String resStr = null;
if (entity1 != null) {
resStr = EntityUtils.toString(entity1, StandardCharsets.UTF_8);
}
httpClient.close();
response.close();
return resStr;
} catch (Exception e) {
log.error("get请求:{},出现错误:{}", url, e.getMessage());
e.printStackTrace();
} finally {
if (httpClient != null) {
httpClient.close();
}
if (response != null) {
response.close();
}
}
return "";
}
}
......@@ -10,6 +10,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>common-mybatis</artifactId>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>8</maven.compiler.source>
......@@ -23,11 +24,13 @@
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.oracle.database.jdbc/ojdbc6 -->
<dependency>
<groupId>com.oracle</groupId>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
<version>11.2.0.4</version>
</dependency>
<!-- 引用Mybatis 和 Mysql驱动结束 -->
</dependencies>
......
......@@ -2,38 +2,39 @@
<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">
<parent>
<artifactId>common</artifactId>
<groupId>com.hungraim.ltc</groupId>
<version>0.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>common</artifactId>
<groupId>com.hungraim.ltc</groupId>
<version>0.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>common-redis</artifactId>
<artifactId>common-redis</artifactId>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<!--redis 依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<!--redis依赖 end-->
</dependencies>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<!--redis 依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<!--redis依赖 end-->
</dependencies>
</project>
......@@ -9,9 +9,9 @@ spring:
nacos:
discovery:
server-addr: qw.hungraim.com:31158
namespace: 87d6f6f1-6583-46ea-ad02-7e8125f03c90
namespace: 0e0f834a-a665-4d27-ae04-9d53c2e02140
config:
namespace: 87d6f6f1-6583-46ea-ad02-7e8125f03c90
namespace: 0e0f834a-a665-4d27-ae04-9d53c2e02140
server-addr: qw.hungraim.com:31158
file-extension: yaml # 必须修改成yaml
extension-configs:
......
......@@ -9,9 +9,9 @@ spring:
nacos:
discovery:
server-addr: qw.hungraim.com:31158
namespace: 87d6f6f1-6583-46ea-ad02-7e8125f03c90
namespace: 0e0f834a-a665-4d27-ae04-9d53c2e02140
config:
namespace: 87d6f6f1-6583-46ea-ad02-7e8125f03c90
namespace: 0e0f834a-a665-4d27-ae04-9d53c2e02140
server-addr: qw.hungraim.com:31158
file-extension: yaml # 必须修改成yaml
extension-configs:
......
<?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>
<modules>
<module>gateway-service</module>
<module>auth-service</module>
<module>common</module>
<module>system</module>
<module>apply</module>
<module>governance</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<packaging>pom</packaging>
<groupId>com.hungraim.ltc</groupId>
<artifactId>ltc</artifactId>
<version>0.0.1</version>
<name>spring-cloud-init</name>
<description>parent</description>
<modelVersion>4.0.0</modelVersion>
<modules>
<module>gateway-service</module>
<module>auth-service</module>
<module>common</module>
<module>system</module>
<module>apply</module>
<module>governance</module>
<module>assessment</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.2.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<packaging>pom</packaging>
<groupId>com.hungraim.ltc</groupId>
<artifactId>ltc</artifactId>
<version>0.0.1</version>
<description>parent</description>
<properties>
<java.version>1.8</java.version>
......
#!/bin/bash
git pull
mvn install
docker stop ltc-poc
docker rmi ltc:latest
docker build -t ltc .
docker run -d --name ltc-poc -p 9999:8001 -m 2G ltc
#指定依赖的镜像
FROM localhost:9999/library/java:8
FROM java:8
#springboot
VOLUME /tmp
#容器使用端口
......
......@@ -10,9 +10,9 @@ spring:
nacos:
discovery:
server-addr: qw.hungraim.com:31158
namespace: 87d6f6f1-6583-46ea-ad02-7e8125f03c90
namespace: 0e0f834a-a665-4d27-ae04-9d53c2e02140
config:
namespace: 87d6f6f1-6583-46ea-ad02-7e8125f03c90
namespace: 0e0f834a-a665-4d27-ae04-9d53c2e02140
server-addr: qw.hungraim.com:31158
file-extension: yaml # 必须修改成yaml
extension-configs:
......
......@@ -2,38 +2,39 @@
<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">
<parent>
<artifactId>system</artifactId>
<groupId>com.hungraim.ltc</groupId>
<version>0.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>system-api</artifactId>
<parent>
<artifactId>system</artifactId>
<groupId>com.hungraim.ltc</groupId>
<version>0.0.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>system-api</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign-core</artifactId>
</dependency>
<dependency>
<groupId>com.hungraim.ltc</groupId>
<artifactId>common-core</artifactId>
<version>0.0.1</version>
</dependency>
</dependencies>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-openfeign-core</artifactId>
</dependency>
<dependency>
<groupId>com.hungraim.ltc</groupId>
<artifactId>common-core</artifactId>
<version>0.0.1</version>
</dependency>
</dependencies>
<distributionManagement>
<repository>
<id>releases</id>
<name>Nexus Release Repository</name>
<url>http://121.5.28.27:9091/nexus/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://121.5.28.27:9091/nexus/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<distributionManagement>
<repository>
<id>releases</id>
<name>Nexus Release Repository</name>
<url>http://121.5.28.27:9091/nexus/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://121.5.28.27:9091/nexus/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment