This commit is contained in:
2024-07-17 11:28:07 +08:00
commit 195e217051
49 changed files with 2741 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
{
"name": "devcontainer",
"image": "registry.cn-hangzhou.aliyuncs.com/zeroware/devcontainer:latest",
"runArgs": ["--name", "${localWorkspaceFolderBasename}_devcontainer", "--env-file",".env"],
"forwardPorts": [
8080
],
"postStartCommand": "git config --global --add safe.directory ${containerWorkspaceFolder}",
"containerUser": "ubuntu",
"remoteUser": "ubuntu",
"containerEnv": {
"HOME": "/home/ubuntu"
},
"remoteEnv": {
"HOME": "/home/ubuntu"
},
"updateRemoteUserUID": true,
"mounts": [
{
"source": "${localEnv:HOME}${localEnv:USERPROFILE}/.m2/repository",
"target": "/home/ubuntu/.m2/repository",
"type": "bind"
},
{
"source": "${localEnv:HOME}${localEnv:USERPROFILE}/.ssh",
"target": "/home/ubuntu/.ssh",
"type": "bind"
}
],
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"extensions": [
"vscjava.vscode-java-dependency",
"vscjava.vscode-maven",
"vscjava.vscode-java-test",
"vscjava.vscode-java-debug",
"vscjava.vscode-java-pack",
"esbenp.prettier-vscode"
]
}
}
}

12
template/.env Normal file
View File

@@ -0,0 +1,12 @@
DB_HOST=116.63.207.117:13306
ROCKETMQ_HOST=116.63.207.117:19876
OPENSEARCH_HOST=116.63.207.117:19200
OPENSEARCH_PASSWORD=UW15/xI9CRFfAexPJWWZ6g
XXL_JOB_ADMIN_ADDRESS=https://xxljob.byteawake.com/xxl-job-admin
XXL_JOB_ADMIN_PASSWORD=7t/IbuxDLIU
REDIS_HOST=116.63.207.117:16379
REDIS_PASSWORD=9P7Alc4bicS/rC992aO45Q

33
template/.gitignore vendored Normal file
View File

@@ -0,0 +1,33 @@
## java
bin/
classes/
## eclipse
.settings/
.classpath
.project
## idea
*.iml
.idea/**
HELP.md
!.idea/dataSources.xml
## vscode
.vscode/
.factorypath
## maven:
target/
test-output/
## system
.DS_Store
logs/
*.log
## vs
.vs
!modules/.gitkeep
.gen

16
template/.idea/dataSources.xml generated Normal file
View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="{{ .db_database }}" uuid="{{ uuidv4 }}">
<driver-ref>mysql.8</driver-ref>
<synchronize>true</synchronize>
{{- if eq .dbType "mysql" }}
<jdbc-driver>com.mysql.cj.jdbc.Driver</jdbc-driver>
{{- else if eq .dbType "postgresql" }}
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
{{- end }}
<jdbc-url>jdbc:{{ .dbType }}://{{ .db_address }}/{{ .db_database }}</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

1
template/.mvn/jvm.config Normal file
View File

@@ -0,0 +1 @@
-Xmx1536m

BIN
template/.mvn/wrapper/maven-wrapper.jar vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,20 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://maven.aliyun.com/repository/public/org/apache/maven/apache-maven/3.8.8/apache-maven-3.8.8-bin.zip
distributionSha256Sum=2e181515ce8ae14b7a904c40bb4794831f5fd1d9641107a13b916af15af4001a
wrapperUrl=https://maven.aliyun.com/repository/public/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
wrapperUrlSha256Sum=e63a53cfb9c4d291ebe3c2b0edacb7622bbc480326beaa5a0456e412f52f066a

1
template/.values.yml Normal file
View File

@@ -0,0 +1 @@
{{ toYaml . }}

21
template/Dockerfile Normal file
View File

@@ -0,0 +1,21 @@
# syntax=registry.cn-hangzhou.aliyuncs.com/imageacc/dockerfile:experimental
FROM registry.cn-hangzhou.aliyuncs.com/zeroware/javaapp-builder:latest as builder
WORKDIR source
COPY ./ ./
ARG JAR_FILE=entrance/web/target/*.jar
RUN --mount=type=cache,target=/root/.m2/repository,rw --mount=type=tmpfs,target=/root/.m2/repository/{{ .groupId | replace "." "/" }} mvnd clean package -Dmaven.test.skip=true
RUN cp ${JAR_FILE} app.jar
RUN java -Djarmode=layertools -jar ./app.jar extract
FROM registry.cn-hangzhou.aliyuncs.com/zeroware/openjdk-17:latest
WORKDIR /application
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
RUN sed -i 's/deb.debian.org/mirrors.aliyun.com/g' /etc/apt/sources.list
COPY --from=builder source/dependencies/ ./
COPY --from=builder source/snapshot-dependencies/ ./
COPY --from=builder source/spring-boot-loader/ ./
COPY --from=builder source/application/ ./
ENV JAVA_OPTS="-Xms512m -Xmx512m"
ENV MAIN_CLASS="org.springframework.boot.loader.JarLauncher"
ENTRYPOINT ["sh", "-c", "exec java ${JAVA_OPTS} -Djava.security.egd=file:dev/./urandom ${MAIN_CLASS}"]

View File

@@ -0,0 +1,5 @@
> 本模块存放公共组件
``` \-- *.utils(工具类; package)
\-- *.enums(公共枚举; package)
\-- *.constants(公共常量; package)
```

80
template/common/pom.xml Normal file
View File

@@ -0,0 +1,80 @@
<?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>{{ .groupId }}</groupId>
<artifactId>{{ .artifactId }}</artifactId>
<version>{{ .version }}</version>
</parent>
<artifactId>{{ .artifactId }}-common</artifactId>
<version>{{ .version }}</version>
<properties>
<elasticsearch.version>7.3.1</elasticsearch.version>
</properties>
<dependencies>
<dependency>
<groupId>com.vs</groupId>
<artifactId>dist</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>ox-basidc-common</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-client</artifactId>
<version>4.9.7</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>vs.common.util</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,14 @@
package {{ .package }}.common.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Data
@Configuration
@ConfigurationProperties(prefix = "rocketmq")
public class MqConfig {
private String nameServer;
private String topic;
private String consumerGroup;
}

View File

@@ -0,0 +1,21 @@
package {{ .package }}.common.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource;
import {{ .package }}.common.config.MqConfig;
import {{ .package }}.common.rocketmq.RocketMQService;
import {{ .package }}.common.rocketmq.RocketMQServiceImpl;
@Configuration
public class RocketMqAutoConfiguration {
@Resource
private MqConfig mqConfig;
@Bean
RocketMQService createRocketMQService() {
RocketMQServiceImpl instance = new RocketMQServiceImpl(mqConfig.getNameServer());
return instance;
}
}

View File

@@ -0,0 +1,2 @@
> 本模块存放公共常量
``` \-- *Constant.java

View File

@@ -0,0 +1,17 @@
package {{ .package }}.common.elasticsearch;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
@ConfigurationProperties(prefix = "essql")
@Component
public class ESConfig {
private String url;
private String password;
private String username;
private String hosts;
private int port;
private String scheme;
}

View File

@@ -0,0 +1,172 @@
package {{ .package }}.common.elasticsearch;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.apache.http.nio.conn.ssl.SSLIOSessionStrategy;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.Nullable;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import javax.net.ssl.*;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import java.util.ArrayList;
import java.util.Objects;
@Configuration
public class EsConfiguration {
private static int connectTimeOut = 1000; // 连接超时时间
private static int socketTimeOut = 30000; // 连接超时时间
private static int connectionRequestTimeOut = 500; // 获取连接的超时时间
private static int maxConnectNum = 100; // 最大连接数
private static int maxConnectPerRoute = 100; // 最大路由连接数
@Resource
private ESConfig esConfig;
private ArrayList<HttpHost> hostList = null;
@PostConstruct
void init(){
hostList = new ArrayList<>();
String[] hostStrs = esConfig.getHosts().split(",");
for (String host : hostStrs) {
hostList.add(new HttpHost(host, esConfig.getPort(), esConfig.getScheme()));
}
}
@Bean
public RestHighLevelClient client() {
RestClientBuilder builder = RestClient.builder(hostList.toArray(new HttpHost[0]));
// 异步httpclient连接延时配置
builder.setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() {
@Override
public RequestConfig.Builder customizeRequestConfig(RequestConfig.Builder requestConfigBuilder) {
requestConfigBuilder.setConnectTimeout(connectTimeOut);
requestConfigBuilder.setSocketTimeout(socketTimeOut);
requestConfigBuilder.setConnectionRequestTimeout(connectionRequestTimeOut);
return requestConfigBuilder;
}
});
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(esConfig.getUsername(), esConfig.getPassword()));
SSLContext sc = null;
try{
sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new SecureRandom());
}catch(KeyManagementException e){
e.printStackTrace();
}catch(NoSuchAlgorithmException e){
e.printStackTrace();
}
SSLIOSessionStrategy sessionStrategy = new SSLIOSessionStrategy(sc, new NullHostNameVerifier());
SecuredHttpClientConfigCallback httpClientConfigCallback = new SecuredHttpClientConfigCallback(sessionStrategy,credentialsProvider);
// 异步httpclient连接数配置
builder.setHttpClientConfigCallback(httpClientConfigCallback);
RestHighLevelClient client = new RestHighLevelClient(builder);
return client;
}
static TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}
}};
public static class NullHostNameVerifier implements HostnameVerifier {
@Override
public boolean verify(String arg0, SSLSession arg1) {
return true;
}
}
class SecuredHttpClientConfigCallback implements RestClientBuilder.HttpClientConfigCallback {
@Nullable
private final CredentialsProvider credentialsProvider;
/**
* The {@link SSLIOSessionStrategy} for all requests to enable SSL / TLS encryption.
*/
private final SSLIOSessionStrategy sslStrategy;
/**
* Create a new {@link SecuredHttpClientConfigCallback}.
*
* @param credentialsProvider The credential provider, if a username/password have been supplied
* @param sslStrategy The SSL strategy, if SSL / TLS have been supplied
* @throws NullPointerException if {@code sslStrategy} is {@code null}
*/
SecuredHttpClientConfigCallback(final SSLIOSessionStrategy sslStrategy,
@Nullable final CredentialsProvider credentialsProvider) {
this.sslStrategy = Objects.requireNonNull(sslStrategy);
this.credentialsProvider = credentialsProvider;
}
/**
* Get the {@link CredentialsProvider} that will be added to the HTTP client.
* @return Can be {@code null}.
*/
@Nullable
CredentialsProvider getCredentialsProvider() {
return credentialsProvider;
}
/**
* Get the {@link SSLIOSessionStrategy} that will be added to the HTTP client.
*
* @return Never {@code null}.
*/
SSLIOSessionStrategy getSSLStrategy() {
return sslStrategy;
}
/**
* Sets the {@linkplain HttpAsyncClientBuilder#setDefaultCredentialsProvider(CredentialsProvider) credential provider},
*
* @param httpClientBuilder The client to configure.
* @return Always {@code httpClientBuilder}.
*/
@Override
public HttpAsyncClientBuilder customizeHttpClient(final HttpAsyncClientBuilder httpClientBuilder) {
// enable SSL / TLS
httpClientBuilder.setSSLStrategy(sslStrategy);
// enable user authentication
if (credentialsProvider != null) {
httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
httpClientBuilder.setMaxConnTotal(maxConnectNum);
httpClientBuilder.setMaxConnPerRoute(maxConnectPerRoute);
return httpClientBuilder;
}
}
}

View File

@@ -0,0 +1,506 @@
package {{ .package }}.common.elasticsearch;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.elasticsearch.action.admin.indices.alias.Alias;
import org.elasticsearch.action.admin.indices.alias.IndicesAliasesRequest;
import org.elasticsearch.action.admin.indices.alias.get.GetAliasesRequest;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.bulk.BulkItemResponse;
import org.elasticsearch.action.bulk.BulkRequest;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.action.delete.DeleteRequest;
import org.elasticsearch.action.delete.DeleteResponse;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.GetAliasesResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.CreateIndexRequest;
import org.elasticsearch.client.indices.CreateIndexResponse;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.PutMappingRequest;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.text.Text;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.rest.RestStatus;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightField;
import org.elasticsearch.search.sort.SortOrder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.json.JSONObject;
import org.springframework.context.annotation.Conditional;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import {{ .package }}.common.utils.JsonUtils;
/**
* es 的工具类
*/
@Component
public class EsService {
@Resource
private RestHighLevelClient restHighLevelClient;
private Logger log = LoggerFactory.getLogger(EsService.class);
/**
* 关键字
*/
public static final String KEYWORD = ".keyword";
/**
* 创建索引
*
* @param index 索引
* @return
*/
public boolean createIndex(String index) throws IOException {
if(isIndexExist(index)){
log.error("Index is exits!");
return false;
}
//1.创建索引请求
CreateIndexRequest request = new CreateIndexRequest(index);
//2.执行客户端请求
CreateIndexResponse response = restHighLevelClient.indices().create(request, RequestOptions.DEFAULT);
log.info("创建索引{}成功",index);
return response.isAcknowledged();
}
/**
* 创建索引并指定分片和复制集数量
* @param indexName
* @param numberOfShards
* @param numberOfReplicas
* @return
* @throws IOException
*/
public boolean createIndexWithShards(String indexName, Integer numberOfShards, Integer numberOfReplicas) throws IOException {
CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName);
//设置分片信息
numberOfShards = numberOfShards == null ? 1 : numberOfShards;
numberOfReplicas = numberOfReplicas == null ? 1 : numberOfReplicas;
createIndexRequest.settings(Settings.builder().
put("index.number_of_shards", numberOfShards)
.put("index.number_of_replicas", numberOfReplicas));
//创建索引
CreateIndexResponse createIndexResponse = restHighLevelClient.indices().create(createIndexRequest, RequestOptions.DEFAULT);
return createIndexResponse.isAcknowledged();
}
/**
* 创建索引,并关联别名
* @param indexName
* @param aliasName
* @return
* @throws IOException
*/
public boolean createIndexWithAlias(String indexName, String aliasName) throws IOException {
CreateIndexRequest request = new CreateIndexRequest(indexName);
if (StringUtils.isNotEmpty(aliasName)) {
request.alias(new Alias(aliasName));
}
CreateIndexResponse createIndexResponse = restHighLevelClient.indices().create(request, RequestOptions.DEFAULT);
return createIndexResponse.isAcknowledged();
}
/**
* 删除索引
*
* @param index
* @return
*/
public boolean deleteIndex(String index) throws IOException {
if(!isIndexExist(index)) {
log.error("Index is not exits!");
return false;
}
//删除索引请求
DeleteIndexRequest request = new DeleteIndexRequest(index);
//执行客户端请求
AcknowledgedResponse delete = restHighLevelClient.indices().delete(request, RequestOptions.DEFAULT);
log.info("删除索引{}成功",index);
return delete.isAcknowledged();
}
/**
* 判断索引是否存在
*
* @param index
* @return
*/
public boolean isIndexExist(String index) throws IOException {
GetIndexRequest request = new GetIndexRequest(index);
boolean exists = restHighLevelClient.indices().exists(request, RequestOptions.DEFAULT);
return exists;
}
/**
* 获取别名关联的index列表
* @param aliasName
* @return
* @throws IOException
*/
public List<String> getIndicesByAlias(String aliasName) throws IOException {
GetAliasesRequest aliasRequest = new GetAliasesRequest(aliasName);
GetAliasesResponse response = restHighLevelClient.indices().getAlias(aliasRequest, RequestOptions.DEFAULT);
if(!RestStatus.OK.equals(response.status())){
return new ArrayList<>();
}
return new ArrayList<>(response.getAliases().keySet());
}
/**
* 新增别名
* @param indexName
* @param aliasName
* @return
* @throws IOException
*/
public boolean addAlias(String indexName, String aliasName) throws IOException {
IndicesAliasesRequest aliasesRequest = new IndicesAliasesRequest();
IndicesAliasesRequest.AliasActions aliasAction =
new IndicesAliasesRequest.AliasActions(IndicesAliasesRequest.AliasActions.Type.ADD)
.index(indexName)
.alias(aliasName);
aliasesRequest.addAliasAction(aliasAction);
AcknowledgedResponse acknowledgedResponse = restHighLevelClient.indices().updateAliases(aliasesRequest,RequestOptions.DEFAULT);
return acknowledgedResponse.isAcknowledged();
}
/**
* 修改别名关联的索引
* @param aliasname
* @param oldIndices
* @param newIndices
* @return
* @throws IOException
*/
public boolean changeAlias(String aliasname, List<String> oldIndices, List<String> newIndices) throws IOException {
IndicesAliasesRequest indicesAliasesRequest = new IndicesAliasesRequest();
for(String newIndexname: newIndices) {
IndicesAliasesRequest.AliasActions addIndexAction = new IndicesAliasesRequest.AliasActions(
IndicesAliasesRequest.AliasActions.Type.ADD).index(newIndexname).alias(aliasname);
indicesAliasesRequest.addAliasAction(addIndexAction);
}
for(String oldIndexname: oldIndices) {
IndicesAliasesRequest.AliasActions removeAction = new IndicesAliasesRequest.AliasActions(
IndicesAliasesRequest.AliasActions.Type.REMOVE).index(oldIndexname).alias(aliasname);
indicesAliasesRequest.addAliasAction(removeAction);
}
AcknowledgedResponse indicesAliasesResponse = restHighLevelClient.indices().updateAliases(indicesAliasesRequest,
RequestOptions.DEFAULT);
return indicesAliasesResponse.isAcknowledged();
}
/**
* 别名是否存在
* @param aliasName
* @return
* @throws IOException
*/
public boolean isAliasExists(String aliasName) throws IOException {
GetAliasesRequest getAliasesRequest = new GetAliasesRequest(aliasName);
return restHighLevelClient.indices().existsAlias(getAliasesRequest, RequestOptions.DEFAULT);
}
/**
* 设置index mapping
* @param request
* @return
* @throws IOException
*/
public boolean addMappingForIndex(PutMappingRequest request) throws IOException {
request.setTimeout(TimeValue.timeValueMinutes(2));
AcknowledgedResponse response = restHighLevelClient.indices().putMapping(request, RequestOptions.DEFAULT);
return response.isAcknowledged();
}
/**
* 数据添加正定ID
*
* @param jsonObject 要增加的数据
* @param index 索引,类似数据库
* @param id 数据ID, 为null时es随机生成
* @return
*/
public String addData(JSONObject jsonObject, String index, String id) throws IOException {
//创建请求
IndexRequest request = new IndexRequest(index);
//规则 put /test_index/_doc/1
request.id(id);
request.timeout(TimeValue.timeValueSeconds(1));
//将数据放入请求 json
IndexRequest source = request.source(jsonObject, XContentType.JSON);
//客户端发送请求
IndexResponse response = restHighLevelClient.index(request, RequestOptions.DEFAULT);
log.info("添加数据成功 索引为: {}, response 状态: {}, id为: {}",index,response.status().getStatus(), response.getId());
return response.getId();
}
public boolean addDataList(List<Pair<Long,?>> datas, String index) throws IOException {
//
BulkRequest bulkRequest = new BulkRequest();
bulkRequest.timeout(TimeValue.timeValueSeconds(10));
IndexRequest request;
if (datas!=null&&datas.size()>0){
for(Pair<Long,?> o: datas){
request = new IndexRequest(index);
String source = JsonUtils.toJson(o.getRight());
request.id(o.getLeft().toString());
request.source(source, XContentType.JSON);
bulkRequest.add(request);
}
}
BulkResponse resp = restHighLevelClient.bulk(bulkRequest,RequestOptions.DEFAULT);
if(resp.hasFailures()){
for(BulkItemResponse itemResponse : resp){
if(itemResponse.isFailed()){
BulkItemResponse.Failure failure = itemResponse.getFailure();
log.warn("同步索引失败index:{}, id:{}, itemId:{}, error: {}", itemResponse.getIndex(), itemResponse.getId(), itemResponse.getItemId(), failure.getMessage());
}
}
}
return !resp.hasFailures();
}
/**
* 数据添加 随机id
*
* @param jsonObject 要增加的数据
* @param index 索引,类似数据库
* @return
*/
public String addData(JSONObject jsonObject, String index) throws IOException {
return addData(jsonObject, index, UUID.randomUUID().toString().replaceAll("-", "").toUpperCase());
}
/**
* 通过ID删除数据
*
* @param index 索引,类似数据库
* @param id 数据ID
*/
public void deleteDataById(String index, String id) throws IOException {
//删除请求
DeleteRequest request = new DeleteRequest(index, id);
//执行客户端请求
DeleteResponse delete = restHighLevelClient.delete(request, RequestOptions.DEFAULT);
log.info("索引为: {}, id为: {}删除数据成功",index, id);
}
/**
* 通过ID 更新数据
*
* @param object 要增加的数据
* @param index 索引,类似数据库
* @param id 数据ID
* @return
*/
public void updateDataById(Object object, String index, String id) throws IOException {
//更新请求
UpdateRequest update = new UpdateRequest(index, id);
//保证数据实时更新
//update.setRefreshPolicy("wait_for");
update.timeout("1s");
update.doc(JsonUtils.toJson(object), XContentType.JSON);
//执行更新请求
UpdateResponse update1 = restHighLevelClient.update(update, RequestOptions.DEFAULT);
log.info("索引为: {}, id为: {}, 更新数据成功",index, id);
}
/**
* 通过ID 更新数据,保证实时性
*
* @param object 要增加的数据
* @param index 索引,类似数据库
* @param id 数据ID
* @return
*/
public void updateDataByIdNoRealTime(Object object, String index, String id) throws IOException {
//更新请求
UpdateRequest update = new UpdateRequest(index, id);
//保证数据实时更新
update.setRefreshPolicy("wait_for");
update.timeout("1s");
update.doc(JsonUtils.toJson(object), XContentType.JSON);
//执行更新请求
UpdateResponse update1 = restHighLevelClient.update(update, RequestOptions.DEFAULT);
log.info("索引为: {}, id为: {}, 更新数据成功",index, id);
}
/**
* 通过ID获取数据
*
* @param index 索引,类似数据库
* @param id 数据ID
* @param fields 需要显示的字段,逗号分隔(缺省为全部字段)
* @return
*/
public Map<String,Object> searchDataById(String index, String id, String fields) throws IOException {
GetRequest request = new GetRequest(index, id);
if (StringUtils.isNotEmpty(fields)){
//只查询特定字段。如果需要查询所有字段则不设置该项。
request.fetchSourceContext(new FetchSourceContext(true,fields.split(","), Strings.EMPTY_ARRAY));
}
GetResponse response = restHighLevelClient.get(request, RequestOptions.DEFAULT);
Map<String, Object> map = response.getSource();
//为返回的数据添加id
map.put("id",response.getId());
return map;
}
/**
* 通过ID判断文档是否存在
* @param index 索引,类似数据库
* @param id 数据ID
* @return
*/
public boolean existsById(String index,String id) throws IOException {
GetRequest request = new GetRequest(index, id);
//不获取返回的_source的上下文
request.fetchSourceContext(new FetchSourceContext(false));
request.storedFields("_none_");
return restHighLevelClient.exists(request, RequestOptions.DEFAULT);
}
/**
* 获取低水平客户端
* @return
*/
public RestClient getLowLevelClient() {
return restHighLevelClient.getLowLevelClient();
}
/**
* 高亮结果集 特殊处理
* map转对象 JSONObject.parseObject(JSONObject.toJSONString(map), Content.class)
* @param searchResponse
* @param highlightField
*/
public List<Map<String, Object>> setSearchResponse(SearchResponse searchResponse, String highlightField) {
//解析结果
ArrayList<Map<String,Object>> list = new ArrayList<>();
for (SearchHit hit : searchResponse.getHits().getHits()) {
Map<String, HighlightField> high = hit.getHighlightFields();
HighlightField title = high.get(highlightField);
hit.getSourceAsMap().put("id", hit.getId());
Map<String, Object> sourceAsMap = hit.getSourceAsMap();//原来的结果
//解析高亮字段,将原来的字段换为高亮字段
if (title!=null){
Text[] texts = title.fragments();
String nTitle="";
for (Text text : texts) {
nTitle+=text;
}
//替换
sourceAsMap.put(highlightField,nTitle);
}
list.add(sourceAsMap);
}
return list;
}
/**
* 查询并分页
* @param index 索引名称
* @param query 查询条件
* @param size 文档大小限制
* @param from 从第几页开始
* @param fields 需要显示的字段,逗号分隔(缺省为全部字段)
* @param sortField 排序字段
* @param highlightField 高亮字段
* @return
*/
public List<Map<String, Object>> searchListData(String index,
SearchSourceBuilder query,
Integer size,
Integer from,
String fields,
String sortField,
String highlightField) throws IOException {
SearchRequest request = new SearchRequest(index);
SearchSourceBuilder builder = query;
if (StringUtils.isNotEmpty(fields)){
//只查询特定字段。如果需要查询所有字段则不设置该项。
builder.fetchSource(new FetchSourceContext(true,fields.split(","),Strings.EMPTY_ARRAY));
}
from = from <= 0 ? 0 : from*size;
//设置确定结果要从哪个索引开始搜索的from选项默认为0
builder.from(from);
builder.size(size);
if (StringUtils.isNotEmpty(sortField)){
//排序字段注意如果proposal_no是text类型会默认带有keyword性质需要拼接.keyword
builder.sort(sortField+".keyword", SortOrder.ASC);
}
//高亮
HighlightBuilder highlight = new HighlightBuilder();
highlight.field(highlightField);
//关闭多个高亮
highlight.requireFieldMatch(false);
highlight.preTags("<span style='color:red'>");
highlight.postTags("</span>");
builder.highlighter(highlight);
//不返回源数据。只有条数之类的数据。
//builder.fetchSource(false);
request.source(builder);
SearchResponse response = restHighLevelClient.search(request, RequestOptions.DEFAULT);
log.error("=="+response.getHits().getTotalHits());
if (response.status().getStatus() == 200) {
// 解析对象
return setSearchResponse(response, highlightField);
}
return null;
}
}

View File

@@ -0,0 +1,26 @@
package {{ .package }}.common.elasticsearch;
import org.apache.commons.lang3.tuple.Pair;
import org.json.JSONException;
import org.springframework.core.ResolvableType;
import java.io.IOException;
import java.util.List;
import org.elasticsearch.client.indices.PutMappingRequest;
import {{ .package }}.common.elasticsearch.EsService;
public interface IndexService {
public boolean indexData(List<Long> ids, String table) throws JSONException, IOException;
public List<String> subscribeTable();
public String mainTable();
public List<Long> scanMainDBIds(long offsetId, int size);
public String indexName();
public PutMappingRequest getIndexMapping();
}

View File

@@ -0,0 +1,2 @@
> 本模块存放公共枚举
``` \-- *Enum.java

View File

@@ -0,0 +1,113 @@
package {{ .package }}.common.redis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
import cn.hutool.core.util.StrUtil;
import org.springframework.beans.factory.annotation.Value;
import java.util.HashSet;
import java.util.Set;
@Configuration
@EnableConfigurationProperties({RedisPoolProperties.class})
public class RedisPoolConfig {
@Autowired
private RedisPoolProperties redisPoolProperties;
@Value("${redis-config.pool.password:}")
private String password;
/**
* 连接池的基本配置
*
* @return JedisPoolConfig
*/
@Bean
public JedisPoolConfig initPoolConfig() {
JedisPoolConfig poolConfig = new JedisPoolConfig();
// 设置最大连接数默认值为8.如果赋值为-1则表示不限制
poolConfig.setMaxTotal(redisPoolProperties.getMaxTotal());
// 最大空闲连接数
poolConfig.setMaxIdle(redisPoolProperties.getMaxIdle());
// 最小空闲连接数
poolConfig.setMinIdle(redisPoolProperties.getMinIdle());
// 获取Jedis连接的最大等待时间单位毫秒默认值为-1表示永不超时。如果超过等待时间则直接抛出JedisConnectionException
poolConfig.setMaxWaitMillis(redisPoolProperties.getMaxWaitMillis());
// 每次释放连接的最大数目
poolConfig.setNumTestsPerEvictionRun(redisPoolProperties.getNumTestsPerEvictionRun());
// 释放连接的扫描间隔(毫秒),如果为负数,则不运行逐出线程, 默认-1
poolConfig.setTimeBetweenEvictionRunsMillis(redisPoolProperties.getTimeBetweenEvictionRunsMillis());
// 连接最小空闲时间
poolConfig.setMinEvictableIdleTimeMillis(redisPoolProperties.getMinEvictableIdleTimeMillis());
// 连接空闲多久后释放, 当空闲时间&gt;该值 且 空闲连接&gt;最大空闲连接数 时直接释放
poolConfig.setSoftMinEvictableIdleTimeMillis(redisPoolProperties.getSoftMinEvictableIdleTimeMillis());
// 在获取Jedis连接时自动检验连接是否可用
poolConfig.setTestOnBorrow(redisPoolProperties.isTestOnBorrow());
// 在将连接放回池中前,自动检验连接是否有效
poolConfig.setTestOnReturn(redisPoolProperties.isTestOnReturn());
// 自动测试池中的空闲连接是否都是可用连接
poolConfig.setTestWhileIdle(redisPoolProperties.isTestWhileIdle());
// 连接耗尽时是否阻塞, false报异常,ture阻塞直到超时, 默认true
poolConfig.setBlockWhenExhausted(redisPoolProperties.isBlockWhenExhausted());
// 是否启用pool的jmx管理功能, 默认true
poolConfig.setJmxEnabled(redisPoolProperties.isJmxEnabled());
// 是否启用后进先出, 默认true
poolConfig.setLifo(redisPoolProperties.isLifo());
// 每次逐出检查时 逐出的最大数目 如果为负数就是 : 1/abs(n), 默认3
poolConfig.setNumTestsPerEvictionRun(redisPoolProperties.getNumTestsPerEvictionRun());
poolConfig.setTestOnBorrow(false);
return poolConfig;
}
/**
* 创建JedisCluster客户端 将redis客户端放到容器中 连接redis集群
* Jedis 连接集群
*
* @return JedisCluster 使用完成后不需要手动释放连接,返回客户端, 使用完成后不需要手动释放连接, 客户端会自动释放连接
*/
// @Bean
// @Qualifier("JedisCluster")
// public JedisCluster getJedisCluster() {
// return new JedisCluster(getSet(), initPoolConfig());
// }
/**
* 单例版 需要手动获取jedis实例用完后需要手动释放
*
* @return 返回redis连接池
*/
@Bean
public JedisPool getRedisPool() {
String host = StrUtil.subBefore(redisPoolProperties.getHostAndPort(), ":", false);
int port = Integer.parseInt(StrUtil.subAfter(redisPoolProperties.getHostAndPort(), ":", false));
if(StrUtil.isNotEmpty(this.password)) {
return new JedisPool(initPoolConfig(),host,port ,1000, password);
}else{
return new JedisPool(initPoolConfig(),host,port);
}
}
/**
* 获取集群对象集合
*
* @return Set
*/
public Set<HostAndPort> getSet() {
String hostAndPortStr = redisPoolProperties.getHostAndPort();
String[] hostAndPortArrays = hostAndPortStr.trim().split(",");
Set<HostAndPort> hostAndPorts = new HashSet<>();
for (String hostAndPort : hostAndPortArrays) {
hostAndPorts.add(new HostAndPort(hostAndPort.split(":")[0], Integer.parseInt(hostAndPort.split(":")[1])));
}
return hostAndPorts;
}
}

View File

@@ -0,0 +1,145 @@
package {{ .package }}.common.redis;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
@Configuration
@ConfigurationProperties(prefix = "redis-config.pool")
public class RedisPoolProperties {
private String hostAndPort;
private int maxTotal;
private int maxIdle;
private int minIdle;
private Long maxWaitMillis;
private Long timeBetweenEvictionRunsMillis;
private Long minEvictableIdleTimeMillis;
private Long softMinEvictableIdleTimeMillis;
private boolean testOnBorrow;
private boolean testOnReturn;
private boolean testWhileIdle;
private boolean blockWhenExhausted;
private boolean jmxEnabled;
private boolean lifo;
private int numTestsPerEvictionRun;
public String getHostAndPort() {
return hostAndPort;
}
public void setHostAndPort(String hostAndPort) {
this.hostAndPort = hostAndPort;
}
public int getMaxTotal() {
return maxTotal;
}
public void setMaxTotal(int maxTotal) {
this.maxTotal = maxTotal;
}
public int getMaxIdle() {
return maxIdle;
}
public void setMaxIdle(int maxIdle) {
this.maxIdle = maxIdle;
}
public int getMinIdle() {
return minIdle;
}
public void setMinIdle(int minIdle) {
this.minIdle = minIdle;
}
public Long getMaxWaitMillis() {
return maxWaitMillis;
}
public void setMaxWaitMillis(Long maxWaitMillis) {
this.maxWaitMillis = maxWaitMillis;
}
public Long getTimeBetweenEvictionRunsMillis() {
return timeBetweenEvictionRunsMillis;
}
public void setTimeBetweenEvictionRunsMillis(Long timeBetweenEvictionRunsMillis) {
this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;
}
public Long getMinEvictableIdleTimeMillis() {
return minEvictableIdleTimeMillis;
}
public void setMinEvictableIdleTimeMillis(Long minEvictableIdleTimeMillis) {
this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;
}
public Long getSoftMinEvictableIdleTimeMillis() {
return softMinEvictableIdleTimeMillis;
}
public void setSoftMinEvictableIdleTimeMillis(Long softMinEvictableIdleTimeMillis) {
this.softMinEvictableIdleTimeMillis = softMinEvictableIdleTimeMillis;
}
public boolean isTestOnBorrow() {
return testOnBorrow;
}
public void setTestOnBorrow(boolean testOnBorrow) {
this.testOnBorrow = testOnBorrow;
}
public boolean isTestOnReturn() {
return testOnReturn;
}
public void setTestOnReturn(boolean testOnReturn) {
this.testOnReturn = testOnReturn;
}
public boolean isTestWhileIdle() {
return testWhileIdle;
}
public void setTestWhileIdle(boolean testWhileIdle) {
this.testWhileIdle = testWhileIdle;
}
public boolean isBlockWhenExhausted() {
return blockWhenExhausted;
}
public void setBlockWhenExhausted(boolean blockWhenExhausted) {
this.blockWhenExhausted = blockWhenExhausted;
}
public boolean isJmxEnabled() {
return jmxEnabled;
}
public void setJmxEnabled(boolean jmxEnabled) {
this.jmxEnabled = jmxEnabled;
}
public boolean isLifo() {
return lifo;
}
public void setLifo(boolean lifo) {
this.lifo = lifo;
}
public int getNumTestsPerEvictionRun() {
return numTestsPerEvictionRun;
}
public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) {
this.numTestsPerEvictionRun = numTestsPerEvictionRun;
}
}

View File

@@ -0,0 +1,7 @@
package {{ .package }}.common.rocketmq;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
public interface RocketMQService {
DefaultMQPushConsumer getConsumer(String consumerGroup);
}

View File

@@ -0,0 +1,34 @@
package {{ .package }}.common.rocketmq;
import lombok.Synchronized;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
import org.apache.rocketmq.client.exception.MQClientException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@Slf4j
public class RocketMQServiceImpl implements RocketMQService {
private String serverAddr = null;
public RocketMQServiceImpl(String serverAddr) {
this.serverAddr = serverAddr;
}
Map<String, DefaultMQPushConsumer> consumerMap = new ConcurrentHashMap<>();
@Override
@Synchronized
public DefaultMQPushConsumer getConsumer(String consumerGroup) {
DefaultMQPushConsumer defaultMQPushConsumer = consumerMap.get(consumerGroup);
if (defaultMQPushConsumer != null) {
return defaultMQPushConsumer;
}
DefaultMQPushConsumer instance = new DefaultMQPushConsumer(consumerGroup);
instance.setNamesrvAddr(this.serverAddr);
this.consumerMap.put(consumerGroup, instance);
return instance;
}
}

View File

@@ -0,0 +1,113 @@
package {{ .package }}.common.utils;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.MissingNode;
import com.vs.ox.common.utils.ObjectMapperFactory;
import java.io.IOException;
import java.util.Optional;
public class JsonUtils {
private static final ObjectMapper objectMapper = ObjectMapperFactory.getDefaultObjectMapper();
static {
objectMapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
}
public static ObjectMapper getObjectMapper() {
return objectMapper;
}
public static String toJson(Object value) {
try {
return objectMapper.writeValueAsString(value);
} catch (JsonProcessingException e) {
throw new IllegalStateException("to Json error", e);
}
}
public static <T> T readObject(String json, TypeReference<T> typeReference) {
return readObject(json, objectMapper.getTypeFactory().constructType(typeReference));
}
public static <T> T readObject(String json, Class<T> clazz) {
return readObject(json, objectMapper.getTypeFactory().constructType(clazz));
}
public static <T> T readObject(byte[] json, Class<T> clazz) {
try {
return objectMapper.readValue(json, clazz);
} catch (IOException e) {
throw new IllegalStateException("read Json error", e);
}
}
public static <T> T readObject(String json, JavaType javaType) {
if (isBlank(json)) {
return null;
}
try {
return objectMapper.readValue(json, javaType);
} catch (IOException e) {
throw new IllegalStateException("read Json error", e);
}
}
public static JsonNode path(String json, String path) {
if (isBlank(json)) {
return MissingNode.getInstance();
}
try {
String atPath = path;
if (!path.startsWith("/")) {
atPath = "/" + path;
}
return objectMapper.readTree(json).at(atPath);
} catch (IOException e) {
throw new IllegalStateException("read Json error", e);
}
}
private static boolean isBlank(String str) {
int strLen;
if (str == null || (strLen = str.length()) == 0) {
return true;
}
for (int i = 0; i < strLen; i++) {
if ((!Character.isWhitespace(str.charAt(i)))) {
return false;
}
}
return true;
}
public static <T> Optional<T> readPath(String json, String path, TypeReference<T> typeReference) {
return readPath(json, path, objectMapper.getTypeFactory().constructType(typeReference));
}
public static <T> Optional<T> readPath(String json, String path, Class<T> clazz) {
JsonNode jsonNode = path(json, path);
if (jsonNode.isMissingNode()) {
return Optional.empty();
}
try {
return Optional.of(objectMapper.treeToValue(jsonNode, clazz));
} catch (JsonProcessingException e) {
throw new IllegalStateException(e);
}
}
public static <T> Optional<T> readPath(String json, String path, JavaType javaType) {
JsonNode jsonNode = path(json, path);
if (jsonNode.isMissingNode()) {
return Optional.empty();
}
return Optional.of(objectMapper.convertValue(jsonNode, javaType));
}
}

View File

@@ -0,0 +1,3 @@
> 本模块存放公共工具类
``` \-- *Util.java
```

34
template/devfile.yaml Normal file
View File

@@ -0,0 +1,34 @@
schemaVersion: 2.2.0
metadata:
name: {{ .projectName }}
components:
- name: tools
container:
image: registry.cn-hangzhou.aliyuncs.com/zeroware/devcontainer:latest
memoryLimit: 4Gi
endpoints:
- name: http
exposure: public
protocol: http
targetPort: 8080
- name: ssh-service
kubernetes:
deployByDefault: true
inlined: |
apiVersion: v1
kind: Service
metadata:
name: {{ .projectName }}-ssh
spec:
ports:
- name: ssh
port: 22222
protocol: TCP
targetPort: 22222
selector:
controller.devfile.io/devworkspace_name: {{ .projectName }}
type: NodePort

View File

@@ -0,0 +1 @@
> 应用入口

View File

@@ -0,0 +1,15 @@
<?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>{{ .groupId }}</groupId>
<artifactId>{{ .artifactId }}-entrance</artifactId>
<version>{{ .version }}</version>
</parent>
<artifactId>{{ .artifactId }}-entrance-mq</artifactId>
<dependencies>
</dependencies>
</project>

View File

@@ -0,0 +1,4 @@
存放消息消费者
```
\-- *Consumer.java
```

View File

@@ -0,0 +1,4 @@
存放DTOConverter
```
\-- *Converter.java
```

View File

@@ -0,0 +1,4 @@
存放DTO
```
\-- *DTO.java
```

View File

@@ -0,0 +1,4 @@
存放工具类
```
\-- *Util.java
```

28
template/entrance/pom.xml Normal file
View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>{{ .groupId }}</groupId>
<artifactId>{{ .artifactId }}</artifactId>
<version>{{ .version }}</version>
</parent>
<artifactId>{{ .artifactId }}-entrance</artifactId>
<version>{{ .version }}</version>
<packaging>pom</packaging>
<dependencies>
<dependency>
<groupId>{{ .groupId }}</groupId>
<artifactId>{{ .artifactId }}-common</artifactId>
<version>{{ .version }}</version>
</dependency>
</dependencies>
<modules>
<module>mq</module>
<module>web</module>
</modules>
</project>

View File

@@ -0,0 +1,55 @@
<?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>{{ .groupId }}</groupId>
<artifactId>{{ .artifactId }}-entrance</artifactId>
<version>{{ .version }}</version>
</parent>
<artifactId>{{ .artifactId }}-entrance-web</artifactId>
<dependencies>
<dependency>
<groupId>com.vs</groupId>
<artifactId>ox-springboot-web-starter</artifactId>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>vs-sqlmapper-spring</artifactId>
</dependency>
<dependency>
<groupId>{{ .groupId }}</groupId>
<artifactId>{{ .artifactId }}-entrance-mq</artifactId>
<version>{{ .version }}</version>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>vs-mock-web</artifactId>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>vs-debug-agent</artifactId>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>vs-debug-plugin</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layers>
<enabled>true</enabled>
</layers>
<skip>false</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,48 @@
package {{ .package }}.entrance.web;
import com.vs.debug.stack.config.EnableVSReplayConfiguration;
import com.vs.sqlmapper.spring.DataSourceConfig;
import com.vs.sqlmapper.spring.scan.VSDaoBeanScan;
import com.vs.mock.config.EnableVSMockConfiguration;
import com.vs.sqlmapper.spring.express.EnableVSMockExpress;
import com.vs.debug.stack.agent.LogStackContextInvokeRecorder;
import com.vs.debug.stack.agent.MethodVisitorHandlerFilter;
import com.vs.debug.stack.agent.StackContextInvokeRecorder;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
/**
* 应用入口
*
* @author byteawake
* @date 2021/5/11 下午5:30
*/
@SpringBootApplication(scanBasePackages = {"{{ .groupId }}", "com.vs", "{{ .groupId }}.index_sync"})
@VSDaoBeanScan(basePackages = {"com.vs","{{ .groupId }}"})
@Import(DataSourceConfig.class)
@EnableVSReplayConfiguration
@EnableVSMockConfiguration
@EnableVSMockExpress
public class AppApplication{
// @Bean(name = "stackContextInvokeRecorder")
// public StackContextInvokeRecorder createStackContextInvokeRecorder() throws Exception {
// return new LogStackContextInvokeRecorder(); // 可以根据需求扩展实现
// }
@Bean
public MethodVisitorHandlerFilter createMethodVisitorHandlerFilter() {
StackContextInvokeRecorder stackContextInvokeRecorder = new LogStackContextInvokeRecorder();
return new MethodVisitorHandlerFilter(stackContextInvokeRecorder);
}
public static void main(String[] args) {
SpringApplication.run(AppApplication.class,args);
}
}

View File

@@ -0,0 +1,83 @@
server.port=8080
endpoints.enabled=false
server.forward-headers-strategy=framework
#custom corss-domain headers, split by ','
cross.domain.headers=
#spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration
base.package={{ .groupId }}
# datasource
spring.datasource.url=jdbc:{{ .dbType }}://${DB_HOST:{{ .dbHost }}:{{ .dbPort }}}/${DB_DATABASE:{{ .dbDatabase }}}?characterEncoding=utf-8&serverTimezone=Asia/Shanghai
spring.datasource.username=${DB_USER:{{ .dbUser }}}
spring.datasource.password=${DB_PASSWORD:{{ .dbPassword }}}
{{- if eq .dbType "mysql" }}
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
{{- else if eq .dbType "postgresql" }}
spring.datasource.driver-class-name=org.postgresql.Driver
{{- end }}
spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource
spring.datasource.tomcat.max-age=3600000
spring.jpa.open-in-view=false
# flyway
spring.flyway.enabled=false
spring.flyway.outOfOrder=true
spring.flyway.baselineOnMigrate=true
mybatis.configuration.map-underscore-to-camel-case=true
#rocketmq
rocketmq.name-server=${ROCKETMQ_HOST:{{ .rocketmq_address }}}
rocketmq.topic=${DB_DATABASE:{{ .rocketmq_topic }}}
rocketmq.consumerGroup={{ .rocketmq_consumerGroup }}
rocketmq.tag=*
rocketmq.producer.group={{ .rocketmq_producerGroup }}
#elasticsearch
essql.hosts=${OPENSEARCH_HOST:{{ .elasticsearch_host }}}
essql.port={{ .elasticsearch_port }}
essql.username=${OPENSEARCH_USER:{{ .elasticsearch_username }}}
essql.password=${OPENSEARCH_PASSWORD:{{ .elasticsearch_password }}}
essql.scheme=${OPENSEARCH_SCHEME:{{ .elasticsearch_scheme }}}
#get user config
get_user_uri={}
#request header
out.request.headers=
#response header
out.response.headers=Content-Type
#eg:https://vsstudio.teitui.com
out.host=
#xxljob
xxl.job.admin.addresses=${XXL_JOB_ADMIN_ADDRESS:{{ .xxljob_address }}}
xxl.job.executor.port=9999
xxl.job.executor.appname={{ .artifactId }}
xxl.job.executor.title={{ .artifactId }}
xxl.job.accessToken={{ .xxljob_accessToken }}
xxl.job.admin.username=${XXL_JOB_ADMIN_USER:{{ .xxljob_username }}}
xxl.job.admin.password=${XXL_JOB_ADMIN_PASSWORD:{{ .xxljob_password }}}
#redis
redis-config.pool.hostAndPort=${REDIS_HOST:{{ .redis_address }}}
redis-config.pool.password=${REDIS_PASSWORD:{{ .redis_password }}}
redis-config.pool.maxTotal={{ .redis_maxTotal }}
redis-config.pool.maxIdle={{ .redis_maxIdle }}
redis-config.pool.minIdle={{ .redis_minIdle }}
redis-config.pool.maxWaitMillis=10000
redis-config.pool.softMinEvictableIdleTimeMillis=10000
redis-config.pool.testOnBorrow=true
redis-config.pool.testOnReturn=true
redis-config.pool.testWhileIdle=true
redis-config.pool.timeBetweenEvictionRunsMillis=30000
redis-config.pool.minEvictableIdleTimeMillis=1800000
redis-config.pool.numTestsPerEvictionRun=3
redis-config.pool.blockWhenExhausted=true
redis-config.pool.jmxEnabled=true
redis-config.pool.lifo=true
#flow config
liteflow.rule-source=el_json:com.vs.flow.FlowRuleSource
liteflow.print-banner=false
liteflow.monitor.enable-log=true

View File

@@ -0,0 +1,82 @@
server.port=8080
endpoints.enabled=false
server.forward-headers-strategy=framework
#custom corss-domain headers, split by ','
cross.domain.headers=
#spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration
base.package={{ .groupId }}
# datasource
spring.datasource.url=jdbc:{{ .dbType }}://${DB_HOST:{{ .dbHost }}:{{ .dbPort }}}/${DB_DATABASE:{{ .dbDatabase }}}?characterEncoding=utf-8&serverTimezone=Asia/Shanghai
spring.datasource.username=${DB_USER:{{ .dbUser }}}
spring.datasource.password=${DB_PASSWORD:{{ .dbPassword }}}
{{- if eq .dbType "mysql" }}
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
{{- else if eq .dbType "postgresql" }}
spring.datasource.driver-class-name=org.postgresql.Driver
{{- end }}
spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource
spring.datasource.tomcat.max-age=3600000
spring.jpa.open-in-view=false
# flyway
spring.flyway.enabled=false
spring.flyway.outOfOrder=true
spring.flyway.baselineOnMigrate=true
mybatis.configuration.map-underscore-to-camel-case=true
#rocketmq
rocketmq.name-server=${ROCKETMQ_HOST}
rocketmq.topic={{ .rocketmq_topic }}
rocketmq.consumerGroup={{ .rocketmq_consumerGroup }}
rocketmq.tag=*
rocketmq.producer.group={{ .rocketmq_producerGroup }}
#elasticsearch
essql.hosts=${OPENSEARCH_HOST}
essql.port={{ .elasticsearch_port }}
essql.username=${OPENSEARCH_USER:admin}
essql.password=${OPENSEARCH_PASSWORD:admin}
essql.scheme=${OPENSEARCH_SCHEME:https}
#get user config
get_user_uri={}
#request header
out.request.headers=
#response header
out.response.headers=Content-Type
out.host=
#xxljob
xxl.job.admin.addresses=${XXL_JOB_ADMIN_ADDRESS}
xxl.job.executor.port=9999
xxl.job.executor.appname={{ .artifactId }}
xxl.job.executor.title={{ .artifactId }}
xxl.job.accessToken={{ .xxljob_accessToken }}
xxl.job.admin.username=${XXL_JOB_ADMIN_USER:admin}
xxl.job.admin.password=${XXL_JOB_ADMIN_PASSWORD:123456}
#redis
redis-config.pool.hostAndPort=${REDIS_HOST}
redis-config.pool.password=${REDIS_PASSWORD}
redis-config.pool.maxTotal={{ .redis_maxTotal }}
redis-config.pool.maxIdle={{ .redis_maxIdle }}
redis-config.pool.minIdle={{ .redis_minIdle }}
redis-config.pool.maxWaitMillis=10000
redis-config.pool.softMinEvictableIdleTimeMillis=10000
redis-config.pool.testOnBorrow=true
redis-config.pool.testOnReturn=true
redis-config.pool.testWhileIdle=true
redis-config.pool.timeBetweenEvictionRunsMillis=30000
redis-config.pool.minEvictableIdleTimeMillis=1800000
redis-config.pool.numTestsPerEvictionRun=3
redis-config.pool.blockWhenExhausted=true
redis-config.pool.jmxEnabled=true
redis-config.pool.lifo=true
#flow config
liteflow.rule-source=el_json:com.vs.flow.FlowRuleSource
liteflow.print-banner=false
liteflow.monitor.enable-log=true

View File

@@ -0,0 +1,83 @@
server.port=8080
endpoints.enabled=false
server.forward-headers-strategy=framework
#custom corss-domain headers, split by ','
cross.domain.headers=
#spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration
base.package={{ .groupId }}
# datasource
spring.datasource.url=jdbc:{{ .dbType }}://${DB_HOST:{{ .dbHost }}:{{ .dbPort }}}/${DB_DATABASE:{{ .dbDatabase }}}?characterEncoding=utf-8&serverTimezone=Asia/Shanghai
spring.datasource.username=${DB_USER:{{ .dbUser }}}
spring.datasource.password=${DB_PASSWORD:{{ .dbPassword }}}
{{- if eq .dbType "mysql" }}
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
{{- else if eq .dbType "postgresql" }}
spring.datasource.driver-class-name=org.postgresql.Driver
{{- end }}
spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource
spring.datasource.tomcat.max-age=3600000
spring.jpa.open-in-view=false
# flyway
spring.flyway.enabled=false
spring.flyway.outOfOrder=true
spring.flyway.baselineOnMigrate=true
mybatis.configuration.map-underscore-to-camel-case=true
#rocketmq
rocketmq.name-server=${ROCKETMQ_HOST:{{ .rocketmq_address }}}
rocketmq.topic=${MYSQL_DATABASE:{{ .rocketmq_topic }}}
rocketmq.consumerGroup={{ .rocketmq_consumerGroup }}
rocketmq.tag=*
rocketmq.producer.group={{ .rocketmq_producerGroup }}
#elasticsearch
essql.hosts=${OPENSEARCH_HOST:{{ .elasticsearch_host }}}
essql.port={{ .elasticsearch_port }}
essql.username=${OPENSEARCH_USER:{{ .elasticsearch_username }}}
essql.password=${OPENSEARCH_PASSWORD:{{ .elasticsearch_password }}}
essql.scheme=${OPENSEARCH_SCHEME:{{ .elasticsearch_scheme }}}
#get user config
get_user_uri={}
#request header
out.request.headers=
#response header
out.response.headers=Content-Type
#eg:https://vsstudio.teitui.com
out.host=
#xxljob
xxl.job.admin.addresses=${XXL_JOB_ADMIN_ADDRESS:{{ .xxljob_address }}}
xxl.job.executor.port=9999
xxl.job.executor.appname={{ .artifactId }}
xxl.job.executor.title={{ .artifactId }}
xxl.job.accessToken={{ .xxljob_accessToken }}
xxl.job.admin.username=${XXL_JOB_ADMIN_USER:{{ .xxljob_username }}}
xxl.job.admin.password=${XXL_JOB_ADMIN_PASSWORD:{{ .xxljob_password }}}
#redis
redis-config.pool.hostAndPort=${REDIS_HOST:{{ .redis_address }}}
redis-config.pool.password=${REDIS_PASSWORD:{{ .redis_password }}}
redis-config.pool.maxTotal={{ .redis_maxTotal }}
redis-config.pool.maxIdle={{ .redis_maxIdle }}
redis-config.pool.minIdle={{ .redis_minIdle }}
redis-config.pool.maxWaitMillis=10000
redis-config.pool.softMinEvictableIdleTimeMillis=10000
redis-config.pool.testOnBorrow=true
redis-config.pool.testOnReturn=true
redis-config.pool.testWhileIdle=true
redis-config.pool.timeBetweenEvictionRunsMillis=30000
redis-config.pool.minEvictableIdleTimeMillis=1800000
redis-config.pool.numTestsPerEvictionRun=3
redis-config.pool.blockWhenExhausted=true
redis-config.pool.jmxEnabled=true
redis-config.pool.lifo=true
#flow config
liteflow.rule-source=el_json:com.vs.flow.FlowRuleSource
liteflow.print-banner=false
liteflow.monitor.enable-log=true

View File

@@ -0,0 +1,5 @@
spring.profiles.active=local
envs=local,remote,online,custom
project_id=${projectId}
project_name={{ .artifactId }}

View File

@@ -0,0 +1,26 @@
[debug.server.host]
// 这块,目前基本是写死这样的配置,不要修改
vs.debug.host = http://vsstudio.teitui.com
[debug.proxy.custom]
// 定义需要增强的classs没有增加的class不记录堆栈
// 一般明显不需要记录的class配置成 class.name=false
// 正则表述式支持,请注意书写
// class.pattern = true 表示要增强记录堆栈的
// 自定义的增加的类
com.vs.entrance.controller.env.register.DebugEnvRegisterTask=false
com.vs.common.util.rpc.pub.PublicInterfaceExecutor = true +[execute]
com.vs.common.util.rpc.pub.PublicInterfaceFilter = true +[doFilter]
org.springframework.http.converter.json.MappingJackson2HttpMessageConverter=true
com.vs.sqlmapper.core.SqlManagerImpl = true +[sqlWatcher]
com.vs.common.util.rpc.RpcMethodExecutor = true
[debug.proxy.service]
// 默认支持serivce下面的所有类放到最后一行
.*?\.service[\.\w_]+ = true -[set*, get*]
.*?\.controller[\.\w_]+ = true -[set*, get*]
.*?\.hibernate[\.\w_]+ = false

View File

@@ -0,0 +1,14 @@
package {{ .package }}.entrance.web;
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 AppApplicationTest {
@Test
public void contextLoads() {
}
}

View File

@@ -0,0 +1 @@

308
template/mvnw vendored Executable file
View File

@@ -0,0 +1,308 @@
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Apache Maven Wrapper startup batch script, version 3.2.0
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /usr/local/etc/mavenrc ] ; then
. /usr/local/etc/mavenrc
fi
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "$(uname)" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
JAVA_HOME="$(/usr/libexec/java_home)"; export JAVA_HOME
else
JAVA_HOME="/Library/Java/Home"; export JAVA_HOME
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=$(java-config --jre-home)
fi
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=$(cygpath --unix "$JAVA_HOME")
[ -n "$CLASSPATH" ] &&
CLASSPATH=$(cygpath --path --unix "$CLASSPATH")
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] &&
JAVA_HOME="$(cd "$JAVA_HOME" || (echo "cannot cd into $JAVA_HOME."; exit 1); pwd)"
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="$(which javac)"
if [ -n "$javaExecutable" ] && ! [ "$(expr "\"$javaExecutable\"" : '\([^ ]*\)')" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=$(which readlink)
if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then
if $darwin ; then
javaHome="$(dirname "\"$javaExecutable\"")"
javaExecutable="$(cd "\"$javaHome\"" && pwd -P)/javac"
else
javaExecutable="$(readlink -f "\"$javaExecutable\"")"
fi
javaHome="$(dirname "\"$javaExecutable\"")"
javaHome=$(expr "$javaHome" : '\(.*\)/bin')
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="$(\unset -f command 2>/dev/null; \command -v java)"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=$(cd "$wdir/.." || exit 1; pwd)
fi
# end of workaround
done
printf '%s' "$(cd "$basedir" || exit 1; pwd)"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
# Remove \r in case we run on Windows within Git Bash
# and check out the repository with auto CRLF management
# enabled. Otherwise, we may read lines that are delimited with
# \r\n and produce $'-Xarg\r' rather than -Xarg due to word
# splitting rules.
tr -s '\r\n' ' ' < "$1"
fi
}
log() {
if [ "$MVNW_VERBOSE" = true ]; then
printf '%s\n' "$1"
fi
}
BASE_DIR=$(find_maven_basedir "$(dirname "$0")")
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}; export MAVEN_PROJECTBASEDIR
log "$MAVEN_PROJECTBASEDIR"
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar"
if [ -r "$wrapperJarPath" ]; then
log "Found $wrapperJarPath"
else
log "Couldn't find $wrapperJarPath, downloading it ..."
if [ -n "$MVNW_REPOURL" ]; then
wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
else
wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
fi
while IFS="=" read -r key value; do
# Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' )
safeValue=$(echo "$value" | tr -d '\r')
case "$key" in (wrapperUrl) wrapperUrl="$safeValue"; break ;;
esac
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
log "Downloading from: $wrapperUrl"
if $cygwin; then
wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath")
fi
if command -v wget > /dev/null; then
log "Found wget ... using wget"
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet"
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
else
wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
log "Found curl ... using curl"
[ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent"
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
else
curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath"
fi
else
log "Falling back to using Java to download"
javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java"
javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaSource=$(cygpath --path --windows "$javaSource")
javaClass=$(cygpath --path --windows "$javaClass")
fi
if [ -e "$javaSource" ]; then
if [ ! -e "$javaClass" ]; then
log " - Compiling MavenWrapperDownloader.java ..."
("$JAVA_HOME/bin/javac" "$javaSource")
fi
if [ -e "$javaClass" ]; then
log " - Running MavenWrapperDownloader.java ..."
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath"
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
# If specified, validate the SHA-256 sum of the Maven wrapper jar file
wrapperSha256Sum=""
while IFS="=" read -r key value; do
case "$key" in (wrapperSha256Sum) wrapperSha256Sum=$value; break ;;
esac
done < "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties"
if [ -n "$wrapperSha256Sum" ]; then
wrapperSha256Result=false
if command -v sha256sum > /dev/null; then
if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c > /dev/null 2>&1; then
wrapperSha256Result=true
fi
elif command -v shasum > /dev/null; then
if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c > /dev/null 2>&1; then
wrapperSha256Result=true
fi
else
echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available."
echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties."
exit 1
fi
if [ $wrapperSha256Result = false ]; then
echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2
echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2
echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2
exit 1
fi
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME")
[ -n "$CLASSPATH" ] &&
CLASSPATH=$(cygpath --path --windows "$CLASSPATH")
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR")
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $*"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
# shellcheck disable=SC2086 # safe args
exec "$JAVACMD" \
$MAVEN_OPTS \
$MAVEN_DEBUG_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

205
template/mvnw.cmd vendored Executable file
View File

@@ -0,0 +1,205 @@
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM http://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Apache Maven Wrapper startup batch script, version 3.2.0
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %WRAPPER_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file
SET WRAPPER_SHA_256_SUM=""
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B
)
IF NOT %WRAPPER_SHA_256_SUM%=="" (
powershell -Command "&{"^
"$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^
"If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^
" Write-Output 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^
" Write-Output 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^
" Write-Output 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^
" exit 1;"^
"}"^
"}"
if ERRORLEVEL 1 goto error
)
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% ^
%JVM_CONFIG_MAVEN_PROPS% ^
%MAVEN_OPTS% ^
%MAVEN_DEBUG_OPTS% ^
-classpath %WRAPPER_JAR% ^
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%"=="on" pause
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
cmd /C exit /B %ERROR_CODE%

284
template/pom.xml Normal file
View File

@@ -0,0 +1,284 @@
<?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.3.7.RELEASE</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>{{ .groupId }}</groupId>
<artifactId>{{ .artifactId }}</artifactId>
<version>{{ .version }}</version>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<junit.version>4.12</junit.version>
<vs.common.util.version>1.2.2</vs.common.util.version>
<vs.common.version>1.2.0</vs.common.version>
<ox.sprintboot.web.starter.version>1.0-SNAPSHOT</ox.sprintboot.web.starter.version>
<lombok.version>1.18.20</lombok.version>
<javax.annotation.api.version>1.3.2</javax.annotation.api.version>
<logback.classic.version>1.2.3</logback.classic.version>
<log4j.version>2.23.1</log4j.version>
<ox.basidc.common>1.0-SNAPSHOT</ox.basidc.common>
<flyway.version>5.2.4</flyway.version>
<vs.common.rpc.version>1.3.0-SNAPSHOT</vs.common.rpc.version>
<vs.sqlmapper.spring>1.0.0-SNAPSHOT</vs.sqlmapper.spring>
<vs.mock.spring>1.0.0-SNAPSHOT</vs.mock.spring>
<vs.elasticsearch.version>1.0.0-SNAPSHOT</vs.elasticsearch.version>
<org.hibernate.core>5.5.7.Final</org.hibernate.core>
<vs.bo.common>1.0-SNAPSHOT</vs.bo.common>
<cn.hutool.all>5.7.4</cn.hutool.all>
<vs.debug.version>1.0.0-SNAPSHOT</vs.debug.version>
<javax.persistence-api>2.2</javax.persistence-api>
<elasticsearch.version>7.3.1</elasticsearch.version>
<dist.version>1.2.2</dist.version>
{{- if eq .dbType "mysql" }}
{{- else if eq .dbType "postgresql" }}
<postgresql.version>42.6.2</postgresql.version>
{{- end }}
</properties>
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>ox-bo-common</artifactId>
<version>${vs.bo.common}</version>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>common-rpc</artifactId>
<version>${vs.common.rpc.version}</version>
</dependency>
{{- if eq .dbType "mysql" }}
{{- else if eq .dbType "postgresql" }}
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
</dependency>
{{- end }}
<!-- uncomment to enable livereload
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency> -->
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${cn.hutool.all}</version>
</dependency>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>${javax.persistence-api}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${org.hibernate.core}</version>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>ox-bo-common</artifactId>
<version>${vs.bo.common}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.6.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>ox-springboot-web-starter</artifactId>
<version>${ox.sprintboot.web.starter.version}</version>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>dist</artifactId>
<version>${dist.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>${javax.annotation.api.version}</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>${logback.classic.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>${log4j.version}</version>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>ox-basidc-common</artifactId>
<version>${ox.basidc.common}</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>${flyway.version}</version>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>common-rpc</artifactId>
<version>${vs.common.rpc.version}</version>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>vs-sqlmapper-spring</artifactId>
<version>${vs.sqlmapper.spring}</version>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>vs-elasticsearch</artifactId>
<version>${vs.elasticsearch.version}</version>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>vs-mock-web</artifactId>
<version>${vs.mock.spring}</version>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>vs-debug-agent</artifactId>
<version>${vs.debug.version}</version>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>vs-debug-plugin</artifactId>
<version>${vs.debug.version}</version>
</dependency>
<dependency>
<groupId>com.vs</groupId>
<artifactId>vs.common.util</artifactId>
<version>${vs.common.util.version}</version>
</dependency>
{{- if eq .db_type "mysql" }}
{{- else if eq .db_type "postgresql" }}
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>
{{- end }}
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.4.1</version>
<executions>
<execution>
<id>enforce</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireJavaVersion>
<version>[11.0,21.0)</version>
</requireJavaVersion>
<requireMavenVersion>
<version>3.8</version>
</requireMavenVersion>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>zeroware-maven-releases</id>
<url>https://repo.byteawake.com/repository/zeroware-maven-releases/</url>
</repository>
<snapshotRepository>
<id>zeroware-maven-snapshots</id>
<url>https://repo.byteawake.com/repository/zeroware-maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
<modules>
<module>entrance</module>
<module>common</module>
</modules>
</project>

3
template/project Normal file
View File

@@ -0,0 +1,3 @@
id={{ .projectId }}
name={{ .projectName | replace "-" "_" }}
version={{ .vsVersion }}

4
template/run.bat Executable file
View File

@@ -0,0 +1,4 @@
@echo off
cd /d %~dp0
.\mvnw.cmd -Dstyle.color=always spring-boot:run %*

5
template/run.sh Executable file
View File

@@ -0,0 +1,5 @@
#!/bin/sh
cd $(dirname $0)
./mvnw -Dstyle.color=always spring-boot:run $@

33
values.yml Normal file
View File

@@ -0,0 +1,33 @@
projectName: test_horsepower1
groupId: com.test_horsepower1
artifactId: '{{ .projectName | replace "-" "_" }}'
applicationName: "{{ .projectName }}-server"
version: 1.0-SNAPSHOT
vsVersion: 1.0.0
projectId: 3fdc654b-feb2-4d4a-be19-e9ca2998b5d6
dbType: mysql
dbHost: 10.0.2.201
dbPort: 3306
package: "{{ .groupId }}.{{ .artifactId }}"
packagePath: '{{ .package | replace "." "/" }}'
dbDatabase: '{{ .projectName | replace "-" "_" }}'
dbUser: '{{ .projectName | replace "-" "_" }}_user'
dbPassword: "{{ randAlphaNum 16 }}"
rocketmq_address: "10.0.2.221:9876;10.0.2.222:9876;10.0.2.223:9876"
rocketmq_topic: '{{ .projectName | replace "-" "_" }}'
rocketmq_consumerGroup: "CID_{{ .artifactId }}"
rocketmq_producerGroup: "PID_{{ .artifactId }}"
elasticsearch_host: "10.0.2.221,10.0.2.222,10.0.2.223"
elasticsearch_port: "9200"
elasticsearch_scheme: "https"
elasticsearch_username: "admin"
elasticsearch_password: "dnZkaNVK"
xxljob_address: "https://xxljob.teitui.com/xxl-job-admin"
xxljob_username: "admin"
xxljob_password: "123456"
xxljob_accessToken: "default_token"
redis_address: "redis.byteawake.com:6379"
redis_password: ""
redis_maxTotal: 100
redis_maxIdle: 10
redis_minIdle: 10