commit d27ec3992b4af9451663bd2e03e2f2f503014105 Author: ycl Date: Thu Dec 4 15:10:09 2025 +0800 int commit diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..3330f82 Binary files /dev/null and b/.DS_Store differ diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/common-springboot-template-spring5-springboot2.iml b/.idea/common-springboot-template-spring5-springboot2.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/common-springboot-template-spring5-springboot2.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..9452703 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..5b416a7 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/template/.gitignore b/template/.gitignore new file mode 100644 index 0000000..c412542 --- /dev/null +++ b/template/.gitignore @@ -0,0 +1,41 @@ +## java +bin/ +classes/ + + +## eclipse +.settings/ +.classpath +.project + +## idea +*.iml +.idea/* +!.idea/codeStyles/ +!.idea/dataSources.xml +HELP.md + +## vscode +.vscode/ +.factorypath + +## maven: +target/ +test-output/ + +## system +.DS_Store +logs/ +*.log + +## vs +.vs +!modules/.gitkeep +.gitattributes +.toco/config.local.yml +_FOSSIL_ +_FOSSIL_-journal +.fslckout +.fslckout-journal + +*.pem \ No newline at end of file diff --git a/template/.idea/codeStyles/Project.xml b/template/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..50e50bb --- /dev/null +++ b/template/.idea/codeStyles/Project.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/template/.idea/codeStyles/codeStyleConfig.xml b/template/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..0f7bc51 --- /dev/null +++ b/template/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + diff --git a/template/.mvn/jvm.config b/template/.mvn/jvm.config new file mode 100644 index 0000000..f432c96 --- /dev/null +++ b/template/.mvn/jvm.config @@ -0,0 +1 @@ +-Xmx1536m \ No newline at end of file diff --git a/template/.mvn/wrapper/maven-wrapper.jar b/template/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000..eebc3c1 Binary files /dev/null and b/template/.mvn/wrapper/maven-wrapper.jar differ diff --git a/template/.mvn/wrapper/maven-wrapper.properties b/template/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000..a3b0533 --- /dev/null +++ b/template/.mvn/wrapper/maven-wrapper.properties @@ -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.9.11/apache-maven-3.9.11-bin.zip +distributionSha256Sum=0d7125e8c91097b36edb990ea5934e6c68b4440eef4ea96510a0f6815e7eeadb +wrapperUrl=https://maven.aliyun.com/repository/public/org/apache/maven/wrapper/maven-wrapper/3.3.4/maven-wrapper-3.3.4.jar +wrapperUrlSha256Sum=4e2fbf6554bc8a4702cdfdd3bef464f423393d784ddbb037216320ce55d5e4e1 diff --git a/template/.toco/README b/template/.toco/README new file mode 100644 index 0000000..37d9861 --- /dev/null +++ b/template/.toco/README @@ -0,0 +1,8 @@ +目录用于存放rules,只支持.md文件。 + +global: 目录用于存放所有agent通用rules +toco: 目录用于存放Toco Agent专用rules,用于外层流程整体控制 +modeling:目录用于存放Modeling Agent专用rules,用于领域建模阶段 +plan: 目录用于存放Plan Agent专用rules,用于整体规划阶段 +design:目录用于存放Design Agent专用rules,用于TOCO设计元素设计 +coding:目录用于存放Coding Agent专用rules,用于编码阶段 \ No newline at end of file diff --git a/template/.toco/design/README b/template/.toco/design/README new file mode 100644 index 0000000..51a2107 --- /dev/null +++ b/template/.toco/design/README @@ -0,0 +1 @@ +目录用于存放Design Agent专用rules,用于TOCO设计元素设计,只支持.md文件 \ No newline at end of file diff --git a/template/.toco/global/README b/template/.toco/global/README new file mode 100644 index 0000000..3ce091c --- /dev/null +++ b/template/.toco/global/README @@ -0,0 +1 @@ +目录用于存放所有agent通用rules,只支持.md文件 \ No newline at end of file diff --git a/template/.toco/modeling/README b/template/.toco/modeling/README new file mode 100644 index 0000000..7aa52d8 --- /dev/null +++ b/template/.toco/modeling/README @@ -0,0 +1 @@ +目录用于存放Modeling Agent专用rules,用于领域建模阶段,只支持.md文件 \ No newline at end of file diff --git a/template/.toco/plan/README b/template/.toco/plan/README new file mode 100644 index 0000000..78bf077 --- /dev/null +++ b/template/.toco/plan/README @@ -0,0 +1 @@ +目录用于存放Plan Agent专用rules,用于整体规划阶段,只支持.md文件 \ No newline at end of file diff --git a/template/.toco/toco/README b/template/.toco/toco/README new file mode 100644 index 0000000..621f823 --- /dev/null +++ b/template/.toco/toco/README @@ -0,0 +1 @@ +目录用于存放Toco Agent专用rules,用于外层流程整体控制,只支持.md文件 \ No newline at end of file diff --git a/template/.values.yml b/template/.values.yml new file mode 100644 index 0000000..106909e --- /dev/null +++ b/template/.values.yml @@ -0,0 +1 @@ +{{ toYaml . }} diff --git a/template/Dockerfile b/template/Dockerfile new file mode 100644 index 0000000..514d0e7 --- /dev/null +++ b/template/Dockerfile @@ -0,0 +1,17 @@ +FROM eclipse-temurin:17.0.16_8-jdk-noble AS builder +WORKDIR source +COPY ./ ./ +ARG JAR_FILE=entrance/web/target/*.jar +RUN ./mvnw clean package -Dmaven.test.skip=true +RUN cp ${JAR_FILE} app.jar +RUN java -Djarmode=layertools -jar ./app.jar extract + +FROM eclipse-temurin:17.0.16_8-jdk-noble +WORKDIR /application +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="-Xms1024m -Xmx1024m" +ENV MAIN_CLASS="org.springframework.boot.loader.JarLauncher" +ENTRYPOINT ["sh", "-c", "exec java ${JAVA_OPTS} -Djava.security.egd=file:dev/./urandom ${MAIN_CLASS}"] diff --git a/template/common/README.md b/template/common/README.md new file mode 100644 index 0000000..2c38b66 --- /dev/null +++ b/template/common/README.md @@ -0,0 +1,5 @@ +> 本模块存放公共组件 +``` \-- *.utils(工具类; package) + \-- *.enums(公共枚举; package) + \-- *.constants(公共常量; package) +``` \ No newline at end of file diff --git a/template/common/pom.xml b/template/common/pom.xml new file mode 100644 index 0000000..eb044c1 --- /dev/null +++ b/template/common/pom.xml @@ -0,0 +1,12 @@ + + + 4.0.0 + + + {{ .groupId }} + {{ .artifactId }} + ${revision} + + {{ .groupId }} + {{ .artifactId }}-common + diff --git a/template/common/src/main/java/{{.packagePath}}/common/constants/README.md b/template/common/src/main/java/{{.packagePath}}/common/constants/README.md new file mode 100644 index 0000000..61310bb --- /dev/null +++ b/template/common/src/main/java/{{.packagePath}}/common/constants/README.md @@ -0,0 +1,2 @@ +> 本模块存放公共常量 +``` \-- *Constant.java \ No newline at end of file diff --git a/template/common/src/main/java/{{.packagePath}}/common/enums/README.md b/template/common/src/main/java/{{.packagePath}}/common/enums/README.md new file mode 100644 index 0000000..f0628a1 --- /dev/null +++ b/template/common/src/main/java/{{.packagePath}}/common/enums/README.md @@ -0,0 +1,2 @@ +> 本模块存放公共枚举 +``` \-- *Enum.java \ No newline at end of file diff --git a/template/common/src/main/java/{{.packagePath}}/common/redis/RedisPoolConfig.java b/template/common/src/main/java/{{.packagePath}}/common/redis/RedisPoolConfig.java new file mode 100644 index 0000000..85ce928 --- /dev/null +++ b/template/common/src/main/java/{{.packagePath}}/common/redis/RedisPoolConfig.java @@ -0,0 +1,57 @@ +package {{ .package }}.common.redis; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import redis.clients.jedis.JedisPool; +import redis.clients.jedis.JedisPoolConfig; +import cn.hutool.core.util.StrUtil; +import org.springframework.beans.factory.annotation.Value; + + + +@Configuration +@EnableConfigurationProperties({RedisPoolProperties.class}) +@ConditionalOnProperty(name = "redis-config.pool.hostAndPort", havingValue = "true") +public class RedisPoolConfig { + @Autowired + private RedisPoolProperties redisPoolProperties; + @Value("${redis-config.pool.password:}") + private String password; + + private JedisPoolConfig initPoolConfig() { + JedisPoolConfig poolConfig = new JedisPoolConfig(); + poolConfig.setMaxTotal(redisPoolProperties.getMaxTotal()); + poolConfig.setMaxIdle(redisPoolProperties.getMaxIdle()); + poolConfig.setMinIdle(redisPoolProperties.getMinIdle()); + poolConfig.setNumTestsPerEvictionRun(redisPoolProperties.getNumTestsPerEvictionRun()); + poolConfig.setTestOnBorrow(redisPoolProperties.isTestOnBorrow()); + poolConfig.setTestOnReturn(redisPoolProperties.isTestOnReturn()); + poolConfig.setTestWhileIdle(redisPoolProperties.isTestWhileIdle()); + poolConfig.setBlockWhenExhausted(redisPoolProperties.isBlockWhenExhausted()); + poolConfig.setJmxEnabled(redisPoolProperties.isJmxEnabled()); + poolConfig.setLifo(redisPoolProperties.isLifo()); + poolConfig.setNumTestsPerEvictionRun(redisPoolProperties.getNumTestsPerEvictionRun()); + poolConfig.setTestOnBorrow(false); + return poolConfig; + } + + + /** + * create jedis poll + * + */ + @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); + } + } + +} diff --git a/template/common/src/main/java/{{.packagePath}}/common/redis/RedisPoolProperties.java b/template/common/src/main/java/{{.packagePath}}/common/redis/RedisPoolProperties.java new file mode 100644 index 0000000..f61c8ec --- /dev/null +++ b/template/common/src/main/java/{{.packagePath}}/common/redis/RedisPoolProperties.java @@ -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; + } +} diff --git a/template/common/src/main/java/{{.packagePath}}/common/response/MyDateFormat.java b/template/common/src/main/java/{{.packagePath}}/common/response/MyDateFormat.java new file mode 100644 index 0000000..0bd8043 --- /dev/null +++ b/template/common/src/main/java/{{.packagePath}}/common/response/MyDateFormat.java @@ -0,0 +1,48 @@ +package {{ .package }}.common.response; + +import java.text.*; +import java.util.Calendar; +import java.util.Date; + +public class MyDateFormat extends DateFormat { + private static final long serialVersionUID = -4580955831439573829L; + private static final String customDateFormat = "yyyy-MM-dd HH:mm:ss"; + private DateFormat dateFormat; + private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + public MyDateFormat(DateFormat dateFormat) { + this.calendar = Calendar.getInstance(); + this.dateFormat = dateFormat; + } + + public StringBuffer format(Date date, StringBuffer toAppendTo, FieldPosition fieldPosition) { + return this.dateFormat.format(date, toAppendTo, fieldPosition); + } + + public Date parse(String source, ParsePosition pos) { + Date date = null; + if (source.length() == "yyyy-MM-dd HH:mm:ss".length()) { + date = this.simpleDateFormat.parse(source, pos); + } else { + date = this.dateFormat.parse(source, pos); + } + + return date; + } + + public Date parse(String source) throws ParseException { + Date date = null; + if (source.length() == "yyyy-MM-dd HH:mm:ss".length()) { + date = this.simpleDateFormat.parse(source); + } else { + date = this.dateFormat.parse(source); + } + + return date; + } + + public Object clone() { + Object format = this.dateFormat.clone(); + return new MyDateFormat((DateFormat)format); + } +} \ No newline at end of file diff --git a/template/common/src/main/java/{{.packagePath}}/common/response/ResponseJsonExceptionResolver.java b/template/common/src/main/java/{{.packagePath}}/common/response/ResponseJsonExceptionResolver.java new file mode 100644 index 0000000..ce5c1f3 --- /dev/null +++ b/template/common/src/main/java/{{.packagePath}}/common/response/ResponseJsonExceptionResolver.java @@ -0,0 +1,109 @@ +package {{ .package }}.common.response; + +import com.vs.common.util.rpc.pub.FailData; +import com.vs.ox.common.exception.ErrorCode; +import com.vs.ox.common.exception.IgnoredException; +import com.vs.ox.common.utils.ObjectMapperFactory; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.core.Ordered; +import org.springframework.http.MediaType; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.http.server.ServletServerHttpResponse; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.validation.ConstraintViolation; +import javax.validation.ConstraintViolationException; +import javax.validation.Path; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +@Slf4j +public class ResponseJsonExceptionResolver extends AbstractHandlerExceptionResolver implements InitializingBean { + private HttpMessageConverter messageConverter; + + public ResponseJsonExceptionResolver() { + } + + @Override + public void afterPropertiesSet() throws Exception { + if (messageConverter == null) { + messageConverter = new MappingJackson2HttpMessageConverter(ObjectMapperFactory.getDefaultObjectMapper()); + } + } + + public static String getErrorInfoFromException(Exception e) { + try { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + e.printStackTrace(pw); + return "\r\n" + sw.toString() + "\r\n"; + } catch (Exception e2) { + return "bad getErrorInfoFromException"; + } + } + + @Override + protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { + /** + * web请求分页单独处理,应对antd框架 + */ + FailData failData = new FailData(); + failData.setMessage(ex.getMessage()); + if (ex instanceof IgnoredException) { + IgnoredException realEx = (IgnoredException) ex; + failData.setCode(realEx.getErrorCode()); + failData.setData(realEx.getData()); + log.error("execute {} failed with exception", request.getRequestURL(), ex); + } else if (ex instanceof ConstraintViolationException) { + failData.setCode(ErrorCode.WRONG_PARAMETER); + failData.setMessage(getMessage((ConstraintViolationException) ex)); + } else if (ex instanceof ErrorCode) { + failData.setCode(((ErrorCode) ex).getErrorCode()); + } else { + log.error("execute {} failed with exception", request.getRequestURL(), ex); + } + try { + response.setCharacterEncoding("utf-8"); + messageConverter.write(failData, MediaType.APPLICATION_JSON, new ServletServerHttpResponse(response)); + } catch (IOException e) { + logger.error(e.getMessage(), e); + } + return new ModelAndView(); + } + + @Override + public int getOrder() { + return Ordered.LOWEST_PRECEDENCE; + } + + public static String getMessage(ConstraintViolationException e) { + List msgList = new ArrayList<>(); + for (ConstraintViolation constraintViolation : e.getConstraintViolations()) { + int i = 0; + StringBuilder param = new StringBuilder(); + for (Iterator iterator = constraintViolation.getPropertyPath().iterator(); iterator.hasNext(); i++) { + Path.Node node = iterator.next(); + if (i == 0) { + continue; + } + if (!param.toString().isBlank()) { + param.append("."); + } + param.append(node.getName()); + } + msgList.add("参数 [ " + param + " ] " + constraintViolation.getMessage()); + } + return StringUtils.join(msgList.toArray(), ";"); + } + +} diff --git a/template/common/src/main/java/{{.packagePath}}/common/response/ResponseJsonMethodReturnValueHandler.java b/template/common/src/main/java/{{.packagePath}}/common/response/ResponseJsonMethodReturnValueHandler.java new file mode 100644 index 0000000..a99592d --- /dev/null +++ b/template/common/src/main/java/{{.packagePath}}/common/response/ResponseJsonMethodReturnValueHandler.java @@ -0,0 +1,49 @@ +package {{ .package }}.common.response; + +import com.vs.common.util.rpc.pub.SuccessData; +import com.vs.ox.common.utils.ObjectMapperFactory; +import org.springframework.beans.factory.InitializingBean; +import org.springframework.core.MethodParameter; +import org.springframework.http.MediaType; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.http.server.ServletServerHttpResponse; +import org.springframework.web.context.request.NativeWebRequest; +import org.springframework.web.method.support.HandlerMethodReturnValueHandler; +import org.springframework.web.method.support.ModelAndViewContainer; + +import javax.servlet.http.HttpServletResponse; +import java.util.Collections; + +/** + * 处理 Controller 里的返回值,从 Object转为Json + */ +public class ResponseJsonMethodReturnValueHandler implements HandlerMethodReturnValueHandler, InitializingBean { + private HttpMessageConverter messageConverter; + + @Override + public void afterPropertiesSet() { + if (messageConverter == null) { + messageConverter = new MappingJackson2HttpMessageConverter(ObjectMapperFactory.getDefaultObjectMapper()); + } + } + + @Override + public boolean supportsReturnType(MethodParameter returnType) { + return true; + } + + @Override + public void handleReturnValue(Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception { + mavContainer.setRequestHandled(true); + Object result = returnValue; + /** + * Web分页请求的返回按照antd框架要求的格式,不转为SuccessData + */ + result = result == null ? new SuccessData(Collections.emptyMap()) : new SuccessData(returnValue); + ServletServerHttpResponse response = new ServletServerHttpResponse(webRequest.getNativeResponse(HttpServletResponse.class)); + messageConverter.write(result, new MediaType(MediaType.APPLICATION_JSON, Collections.singletonMap("charset", "utf-8")), response); + } + + +} diff --git a/template/common/src/main/java/{{.packagePath}}/common/response/WebMvcConfiguration.java b/template/common/src/main/java/{{.packagePath}}/common/response/WebMvcConfiguration.java new file mode 100644 index 0000000..90e9315 --- /dev/null +++ b/template/common/src/main/java/{{.packagePath}}/common/response/WebMvcConfiguration.java @@ -0,0 +1,104 @@ +package {{ .package }}.common.response; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.beans.BeansException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.method.annotation.MapMethodProcessor; +import org.springframework.web.method.support.HandlerMethodReturnValueHandler; +import org.springframework.web.servlet.HandlerExceptionResolver; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; +import org.springframework.web.servlet.mvc.method.annotation.ViewNameMethodReturnValueHandler; + +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import java.text.DateFormat; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +@Configuration +@ComponentScan("com.vs.ox") +public class +WebMvcConfiguration extends WebMvcConfigurerAdapter implements ApplicationContextAware { + RequestMappingHandlerAdapter requestMappingHandlerAdapter; + ApplicationContext applicationContext; + + void init() { + List returnValueHandlers = this.requestMappingHandlerAdapter.getReturnValueHandlers(); + Iterator iterator = returnValueHandlers.iterator(); + List newProcessors = new ArrayList<>(); + while (iterator.hasNext()) { + HandlerMethodReturnValueHandler next = iterator.next(); + //为了能在controller中直接返回map,不被默认的MapMethodProcessor拦截 + if (next instanceof MapMethodProcessor || + //为了能在controller中直接返回String,不被默认的ViewNameMethodReturnValueHandler拦截 + next instanceof ViewNameMethodReturnValueHandler) { + continue; + } else { + newProcessors.add(next); + } + } + this.requestMappingHandlerAdapter.setReturnValueHandlers(newProcessors); + } + + + @Override + public void extendHandlerExceptionResolvers(List exceptionResolvers) { + ResponseJsonExceptionResolver responseJsonExceptionResolver = new ResponseJsonExceptionResolver(); + try { + responseJsonExceptionResolver.afterPropertiesSet(); + } catch (Exception e) { + e.printStackTrace(); + } + exceptionResolvers.add(responseJsonExceptionResolver); + } + + @Override + public void addReturnValueHandlers(List returnValueHandlers) { + ResponseJsonMethodReturnValueHandler responseJsonMethodReturnValueHandler = new ResponseJsonMethodReturnValueHandler(); + responseJsonMethodReturnValueHandler.afterPropertiesSet(); + returnValueHandlers.add(responseJsonMethodReturnValueHandler); + } + + @Override + public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { + this.applicationContext = applicationContext; + } + + @Autowired + private Jackson2ObjectMapperBuilder jackson2ObjectMapperBuilder; + + @Bean + public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() { + ObjectMapper mapper = jackson2ObjectMapperBuilder.build(); + DateFormat dateFormat = mapper.getDateFormat(); + mapper.setDateFormat(new MyDateFormat(dateFormat)); + MappingJackson2HttpMessageConverter mappingJsonpHttpMessageConverter = new MappingJackson2HttpMessageConverter(mapper); + return mappingJsonpHttpMessageConverter; + } + + @Bean + ServletContextListener listener1() { + return new ServletContextListener() { + @Override + public void contextInitialized(ServletContextEvent sce) { + requestMappingHandlerAdapter = applicationContext.getBean(RequestMappingHandlerAdapter.class); + init(); + ServletContextListener.super.contextInitialized(sce); + } + + @Override + public void contextDestroyed(ServletContextEvent sce) { + ServletContextListener.super.contextDestroyed(sce); + } + }; + } +} \ No newline at end of file diff --git a/template/common/src/main/java/{{.packagePath}}/common/utils/JsonUtils.java b/template/common/src/main/java/{{.packagePath}}/common/utils/JsonUtils.java new file mode 100644 index 0000000..137bd3c --- /dev/null +++ b/template/common/src/main/java/{{.packagePath}}/common/utils/JsonUtils.java @@ -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 readObject(String json, TypeReference typeReference) { + return readObject(json, objectMapper.getTypeFactory().constructType(typeReference)); + } + + public static T readObject(String json, Class clazz) { + return readObject(json, objectMapper.getTypeFactory().constructType(clazz)); + } + + public static T readObject(byte[] json, Class clazz) { + try { + return objectMapper.readValue(json, clazz); + } catch (IOException e) { + throw new IllegalStateException("read Json error", e); + } + } + + public static 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 Optional readPath(String json, String path, TypeReference typeReference) { + return readPath(json, path, objectMapper.getTypeFactory().constructType(typeReference)); + } + + public static Optional readPath(String json, String path, Class 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 Optional 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)); + } +} diff --git a/template/common/src/main/java/{{.packagePath}}/common/utils/README.md b/template/common/src/main/java/{{.packagePath}}/common/utils/README.md new file mode 100644 index 0000000..f4bb11f --- /dev/null +++ b/template/common/src/main/java/{{.packagePath}}/common/utils/README.md @@ -0,0 +1,3 @@ +> 本模块存放公共工具类 +``` \-- *Util.java +``` \ No newline at end of file diff --git a/template/entrance/README.md b/template/entrance/README.md new file mode 100644 index 0000000..57f8ae9 --- /dev/null +++ b/template/entrance/README.md @@ -0,0 +1 @@ +> 应用入口 \ No newline at end of file diff --git a/template/entrance/mq/pom.xml b/template/entrance/mq/pom.xml new file mode 100644 index 0000000..72af7e9 --- /dev/null +++ b/template/entrance/mq/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + + + {{ .groupId }} + {{ .artifactId }}-entrance + ${revision} + + + {{ .artifactId }}-entrance-mq + + + + diff --git a/template/entrance/mq/src/main/java/{{.packagePath}}/entrance/mq/consumer/README.md b/template/entrance/mq/src/main/java/{{.packagePath}}/entrance/mq/consumer/README.md new file mode 100644 index 0000000..3149556 --- /dev/null +++ b/template/entrance/mq/src/main/java/{{.packagePath}}/entrance/mq/consumer/README.md @@ -0,0 +1,4 @@ +存放消息消费者 +``` +\-- *Consumer.java +``` \ No newline at end of file diff --git a/template/entrance/mq/src/main/java/{{.packagePath}}/entrance/mq/converter/README.md b/template/entrance/mq/src/main/java/{{.packagePath}}/entrance/mq/converter/README.md new file mode 100644 index 0000000..c98a339 --- /dev/null +++ b/template/entrance/mq/src/main/java/{{.packagePath}}/entrance/mq/converter/README.md @@ -0,0 +1,4 @@ +存放DTOConverter +``` +\-- *Converter.java +``` \ No newline at end of file diff --git a/template/entrance/mq/src/main/java/{{.packagePath}}/entrance/mq/dto/README.md b/template/entrance/mq/src/main/java/{{.packagePath}}/entrance/mq/dto/README.md new file mode 100644 index 0000000..815f9be --- /dev/null +++ b/template/entrance/mq/src/main/java/{{.packagePath}}/entrance/mq/dto/README.md @@ -0,0 +1,4 @@ +存放DTO +``` +\-- *DTO.java +``` \ No newline at end of file diff --git a/template/entrance/mq/src/main/java/{{.packagePath}}/entrance/mq/utils/README.md b/template/entrance/mq/src/main/java/{{.packagePath}}/entrance/mq/utils/README.md new file mode 100644 index 0000000..b81edcb --- /dev/null +++ b/template/entrance/mq/src/main/java/{{.packagePath}}/entrance/mq/utils/README.md @@ -0,0 +1,4 @@ +存放工具类 +``` +\-- *Util.java +``` \ No newline at end of file diff --git a/template/entrance/pom.xml b/template/entrance/pom.xml new file mode 100644 index 0000000..e94c4d7 --- /dev/null +++ b/template/entrance/pom.xml @@ -0,0 +1,23 @@ + + + + 4.0.0 + + {{ .groupId }} + {{ .artifactId }} + ${revision} + + {{ .artifactId }}-entrance + pom + + + {{ .groupId }} + {{ .artifactId }}-common + ${revision} + + + + mq + web + + \ No newline at end of file diff --git a/template/entrance/web/pom.xml b/template/entrance/web/pom.xml new file mode 100644 index 0000000..c8d7b80 --- /dev/null +++ b/template/entrance/web/pom.xml @@ -0,0 +1,32 @@ + + + 4.0.0 + + {{ .groupId }} + {{ .artifactId }}-entrance + ${revision} + + {{ .artifactId }}-entrance-web + + + {{ .groupId }} + {{ .artifactId }}-entrance-mq + ${revision} + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + true + + false + + + + + diff --git a/template/entrance/web/src/main/java/{{.packagePath}}/entrance/web/AppApplication.java b/template/entrance/web/src/main/java/{{.packagePath}}/entrance/web/AppApplication.java new file mode 100644 index 0000000..c15db93 --- /dev/null +++ b/template/entrance/web/src/main/java/{{.packagePath}}/entrance/web/AppApplication.java @@ -0,0 +1,27 @@ +package {{ .package }}.entrance.web; + +import com.vs.sqlmapper.spring.DataSourceConfig; +import com.vs.sqlmapper.spring.scan.VSDaoBeanScan; +import com.vs.agent.TocoAgentInitializer; + +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; +import org.springframework.scheduling.annotation.EnableScheduling; + + +@SpringBootApplication(scanBasePackages = {"{{.groupId}}", "com.vs"}) +@VSDaoBeanScan(basePackages = {"com.vs","{{.groupId}}"}) +@Import(DataSourceConfig.class) +@MapperScan("{{.groupId}}.**.persist.mapper.mybatis") +@EnableScheduling +public class AppApplication{ + + public static void main(String[] args) { + SpringApplication application = new SpringApplication(AppApplication.class); + application.addInitializers(new TocoAgentInitializer()); + application.run(args); + } +} diff --git a/template/entrance/web/src/main/java/{{.packagePath}}/entrance/web/config/SSLConfig.java b/template/entrance/web/src/main/java/{{.packagePath}}/entrance/web/config/SSLConfig.java new file mode 100644 index 0000000..ce97ed4 --- /dev/null +++ b/template/entrance/web/src/main/java/{{.packagePath}}/entrance/web/config/SSLConfig.java @@ -0,0 +1,71 @@ +package {{ .package }}.entrance.web.config; + +import org.apache.catalina.connector.Connector; +import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; +import org.springframework.boot.web.servlet.server.ServletWebServerFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.env.Environment; +import org.springframework.core.io.ClassPathResource; + +import java.io.IOException; + +@Configuration +public class SSLConfig { + + @Bean + public ServletWebServerFactory servletContainer(Environment env) { + TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); + + // 禁用自动配置的SSL(如果存在) + tomcat.setRegisterDefaultServlet(false); + + if (hasSslConfig(env)) { + tomcat.addAdditionalTomcatConnectors(createSslConnector(env)); + } + + return tomcat; + } + + private boolean hasSslConfig(Environment env) { + return env.containsProperty("ssl_certificate") + && env.containsProperty("ssl_certificate-private-key"); + } + + private Connector createSslConnector(Environment env) { + String certPath = env.getProperty("ssl_certificate"); + String keyPath = env.getProperty("ssl_certificate-private-key"); + String httpsPort = env.getProperty("server.https.port", "8443"); + + Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); + connector.setScheme("https"); + connector.setSecure(true); + connector.setPort(Integer.parseInt(httpsPort)); + + // 明确设置SSL配置 + connector.setProperty("SSLEnabled", "true"); + connector.setProperty("sslProtocol", "TLS"); + connector.setProperty("clientAuth", "false"); + connector.setProperty("sslEnabledProtocols", "TLSv1.2,TLSv1.3"); + + // 处理证书路径 + connector.setProperty("certificateFile", extractFilePath(certPath)); + connector.setProperty("certificateKeyFile", extractFilePath(keyPath)); + + return connector; + } + + private String extractFilePath(String classpathResource) { + if (classpathResource == null) return null; + + if (classpathResource.startsWith("classpath:")) { + String resource = classpathResource.substring("classpath:".length()); + try { + return new ClassPathResource(resource).getFile().getAbsolutePath(); + } catch (IOException e) { + throw new RuntimeException("Failed to locate SSL certificate file", e); + } + } + return classpathResource; + } +} \ No newline at end of file diff --git a/template/entrance/web/src/main/resources/application-local.properties b/template/entrance/web/src/main/resources/application-local.properties new file mode 100644 index 0000000..a49f078 --- /dev/null +++ b/template/entrance/web/src/main/resources/application-local.properties @@ -0,0 +1,17 @@ +server.port=8082 + +mock.enabled=true +#datasource +{{- if eq .dbType "oracle" }} +spring.datasource.url=jdbc:oracle:thin:@//{{ .dbHost }}:{{ .dbPort }}/ORCLCDB +{{- else if eq .dbType "postgresql" }} +spring.datasource.url=jdbc:postgresql://{{ .dbHost }}:{{ .dbPort }}/{{ .dbDatabase }}?useUnicode=true&characterEncoding=utf8&autoReconnect=true&stringtype=unspecified +{{- else if eq .dbType "mysql" }} +spring.datasource.url=jdbc:mysql://${DB_HOST:10.0.2.201:3306}/${DB_DATABASE:hande_test}?characterEncoding=utf-8&serverTimezone=Asia/Shanghai +{{- else if eq .dbType "dm"}} +spring.datasource.url=jdbc:dm://${ .dbHost }/${ .dbPort }/SYSDBA?characterEncoding=utf-8&serverTimezone=Asia/Shanghai +{{- end }} +spring.datasource.username=${DB_USER:hande_test_user} +spring.datasource.password=${DB_PASSWORD:Yu0FvhjUQDGdnmm5} +spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource +spring.datasource.tomcat.max-age=3600000 \ No newline at end of file diff --git a/template/entrance/web/src/main/resources/application-online.properties b/template/entrance/web/src/main/resources/application-online.properties new file mode 100644 index 0000000..f15c810 --- /dev/null +++ b/template/entrance/web/src/main/resources/application-online.properties @@ -0,0 +1,17 @@ +server.port=8080 + +#datasource +{{- if eq .dbType "oracle" }} +spring.datasource.url=jdbc:oracle:thin:@//{{ .dbHost }}:{{ .dbPort }}/ORCLCDB +{{- else if eq .dbType "postgresql" }} +spring.datasource.url=jdbc:postgresql://{{ .dbHost }}:{{ .dbPort }}/{{ .dbDatabase }}?useUnicode=true&characterEncoding=utf8&autoReconnect=true&stringtype=unspecified +{{- else if eq .dbType "mysql" }} +spring.datasource.url=jdbc:mysql://${DB_HOST:10.0.2.201:3306}/${DB_DATABASE:hande_test}?characterEncoding=utf-8&serverTimezone=Asia/Shanghai +{{- else if eq .dbType "dm"}} +spring.datasource.url=jdbc:dm://${ .dbHost }/${ .dbPort }/SYSDBA?characterEncoding=utf-8&serverTimezone=Asia/Shanghai +{{- end }} +spring.datasource.username=${DB_USER:hande_test_user} +spring.datasource.password=${DB_PASSWORD:Yu0FvhjUQDGdnmm5} +spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource + + diff --git a/template/entrance/web/src/main/resources/application-remote.properties b/template/entrance/web/src/main/resources/application-remote.properties new file mode 100644 index 0000000..bb29233 --- /dev/null +++ b/template/entrance/web/src/main/resources/application-remote.properties @@ -0,0 +1,15 @@ +server.port=8080 + +#datasource +{{- if eq .dbType "oracle" }} +spring.datasource.url=jdbc:oracle:thin:@//{{ .dbHost }}:{{ .dbPort }}/ORCLCDB +{{- else if eq .dbType "postgresql" }} +spring.datasource.url=jdbc:postgresql://{{ .dbHost }}:{{ .dbPort }}/{{ .dbDatabase }}?useUnicode=true&characterEncoding=utf8&autoReconnect=true&stringtype=unspecified +{{- else if eq .dbType "mysql" }} +spring.datasource.url=jdbc:mysql://${DB_HOST:10.0.2.201:3306}/${DB_DATABASE:hande_test}?characterEncoding=utf-8&serverTimezone=Asia/Shanghai +{{- else if eq .dbType "dm"}} +spring.datasource.url=jdbc:dm://${ .dbHost }/${ .dbPort }/SYSDBA?characterEncoding=utf-8&serverTimezone=Asia/Shanghai +{{- end }} +spring.datasource.username=${DB_USER:hande_test_user} +spring.datasource.password=${DB_PASSWORD:Yu0FvhjUQDGdnmm5} +spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource diff --git a/template/entrance/web/src/main/resources/application.properties b/template/entrance/web/src/main/resources/application.properties new file mode 100644 index 0000000..1f8276f --- /dev/null +++ b/template/entrance/web/src/main/resources/application.properties @@ -0,0 +1,71 @@ +spring.profiles.active=local +envs=local,remote,online,custom +check=true +spring.main.allow-bean-definition-overriding=true +spring.mvc.pathmatch.matching-strategy=ANT_PATH_MATCHER +spring.jpa.open-in-view=false +spring.main.allow-circular-references=true +spring.login.security.csrf=false +application.name={{ .projectName }} +mybatis.configuration.map-underscore-to-camel-case=true +project_id={{ .projectId }} +project_name={{ .projectName }} +base.package={{.groupId}} +{{- 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 +vs.sqlmapper.dialect=postgresql +spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect +hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect +{{- else if eq .dbType "oracle" }} +spring.datasource.driver-class-name=oracle.jdbc.OracleDriver +hibernate.dialect=org.hibernate.dialect.Oracle10gDialect +vs.sqlmapper.dialect=oracle +{{- else if eq .dbType "dm" }} +spring.datasource.driver-class-name=dm.jdbc.driver.DmDriver +hibernate.dialect=org.hibernate.dialect.DmDialect +vs.sqlmapper.dialect=dm +{{- end }} +com.toco.agent.attach=false + +#create default table +vs.db.basetable.create=true +server.ssl.enabled=false +server.forward-headers-strategy=framework +#request header +out.request.headers= +#response header +out.response.headers=Content-Type +#custom corss-domain headers, split by ',' +cross.domain.headers= +#eg:https://vsstudio.teitui.com +out.host= +#hibernate.show_sql=true +#vs.sqlmapper.showSql=true +mock.enabled=false + +## message config , use memory for test, mq.type can be redis/rocketmq/kafka +mq.type=memory + +#rocketmq.name-server=${ROCKETMQ_HOST:10.0.2.221:9876;10.0.2.222:9876;10.0.2.223:9876} + +#redis +#redis-config.pool.hostAndPort=${REDIS_HOST:redis.byteawake.com:6379} +#redis-config.pool.password=${REDIS_PASSWORD:} +#redis-config.pool.maxTotal=100 +#redis-config.pool.maxIdle=10 +#redis-config.pool.minIdle=10 +#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 + +#kafka.bootstrap-servers=localhost:9092 diff --git a/template/entrance/web/src/main/resources/visitor_agents.conf b/template/entrance/web/src/main/resources/visitor_agents.conf new file mode 100644 index 0000000..ae84c2a --- /dev/null +++ b/template/entrance/web/src/main/resources/visitor_agents.conf @@ -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 \ No newline at end of file diff --git a/template/modules/.gitkeep b/template/modules/.gitkeep new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/template/modules/.gitkeep @@ -0,0 +1 @@ + diff --git a/template/mvnw b/template/mvnw new file mode 100755 index 0000000..8d937f4 --- /dev/null +++ b/template/mvnw @@ -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 "$@" diff --git a/template/mvnw.cmd b/template/mvnw.cmd new file mode 100755 index 0000000..c4586b5 --- /dev/null +++ b/template/mvnw.cmd @@ -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% diff --git a/template/pom.xml b/template/pom.xml new file mode 100644 index 0000000..f2942f8 --- /dev/null +++ b/template/pom.xml @@ -0,0 +1,317 @@ + + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.7.18 + + + {{ .groupId }} + {{ .artifactId }} + ${revision} + pom + + UTF-8 + 11 + 11 + UTF-8 + 3.0-SNAPSHOT + {{- if eq .dbType "dm" }} + 18 + 8.1.3.140 + {{- end }} + + + + cn.hutool + hutool-all + 5.7.4 + + + javax.persistence + javax.persistence-api + 2.2 + + + junit + junit + 4.13 + test + + + ch.qos.logback + logback-classic + 1.2.3 + + + org.json + json + 20170516 + + + org.apache.httpcomponents + httpasyncclient + 4.1.5 + + + org.springframework + spring-webmvc + 5.3.14 + + + org.slf4j + slf4j-api + 1.7.30 + + + com.google.guava + guava + 23.0 + + + org.apache.httpcomponents + httpclient + 4.5.13 + + + org.apache.httpcomponents + httpmime + 4.5.13 + + + com.fasterxml.jackson.core + jackson-databind + 2.13.0 + + + javax.servlet + javax.servlet-api + 4.0.1 + provided + + + javax.validation + validation-api + 2.0.1.Final + + + cglib + cglib-nodep + 3.3.0 + + + com.xuxueli + xxl-job-core + 2.2.0 + + + org.apache.commons + commons-lang3 + 3.12.0 + + + org.springframework + spring-context + 5.3.14 + + + org.aspectj + aspectjrt + 1.9.6 + + + org.springframework.boot + spring-boot-autoconfigure + 2.7.18 + + + redis.clients + jedis + 3.3.0 + + + org.springframework + spring-web + 5.3.14 + + + org.springframework.boot + spring-boot-starter-data-jpa + 2.6.3 + + + org.hibernate.validator + hibernate-validator + 6.1.6.Final + + + javax.transaction + javax.transaction-api + 1.3 + + + javax.annotation + javax.annotation-api + 1.3.2 + + + cn.hutool + hutool-all + 5.7.4 + + + org.projectlombok + lombok + 1.18.20 + + + commons-collections + commons-collections + 3.2.2 + + + org.springframework.boot + spring-boot-dependencies + 2.6.2 + pom + import + + + commons-logging + commons-logging + 1.2 + + + com.caucho + hessian + 4.0.63 + + + io.jsonwebtoken + jjwt + 0.9.1 + + + org.hibernate + hibernate-core + 5.5.7.Final + + + io.github.think-1024 + toco-all-spring5-springboot2-community + 1.0 + + + org.apache.tomcat.embed + tomcat-embed-core + 9.0.56 + provided + + + org.apache.tomcat + tomcat-jdbc + 9.0.56 + + + org.glassfish + javax.el + 3.0.0 + + + org.apache.logging.log4j + log4j-core + 2.17.0 + + + com.baomidou + mybatis-plus-boot-starter + 3.5.7 + + + com.alibaba + transmittable-thread-local + 2.12.3 + + {{- if eq .dbType "dm" }} + + dm + DmJdbcDriver + 18 + + + com.dameng + DmDialect-for-hibernate5.6 + 8.1.3.140 + + {{- else if eq .dbType "mysql" }} + + mysql + mysql-connector-java + 8.0.27 + + {{- else if eq .dbType "postgresql" }} + + org.postgresql + postgresql + 42.6.2 + + {{- else if eq .dbType "oracle" }} + + com.oracle + ojdbc8 + 12.2.0.1 + + {{- end }} + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.4.1 + + + enforce + + enforce + + + + + [11.0,21.0) + + + 3.8 + + + true + + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.3.1 + + UTF-8 + + + + org.springframework.boot + spring-boot-maven-plugin + + true + + + + + + entrance + common + + \ No newline at end of file diff --git a/template/project b/template/project new file mode 100644 index 0000000..aec3bd0 --- /dev/null +++ b/template/project @@ -0,0 +1,3 @@ +id={{ .projectId }} +name={{ .projectName | replace "-" "_" }} +version={{ .vsVersion }} \ No newline at end of file diff --git a/template/run.bat b/template/run.bat new file mode 100755 index 0000000..e9956c1 --- /dev/null +++ b/template/run.bat @@ -0,0 +1,4 @@ +@echo off +cd /d %~dp0 + +.\mvnw.cmd -Dstyle.color=always spring-boot:run %* diff --git a/template/run.sh b/template/run.sh new file mode 100755 index 0000000..9d027d7 --- /dev/null +++ b/template/run.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +cd $(dirname $0) + +./mvnw -Dstyle.color=always spring-boot:run $@ diff --git a/values.yml b/values.yml new file mode 100644 index 0000000..710dfba --- /dev/null +++ b/values.yml @@ -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