Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 19439a218a | |||
| d1955f9602 | |||
| 0bb53edd3b | |||
| e5032e7099 | |||
| d2f4deb15f |
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
.toco
|
||||
.idea/
|
||||
.vscode/
|
||||
.DS_Store
|
||||
@@ -1,60 +0,0 @@
|
||||
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 org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
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;
|
||||
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties({RedisPoolProperties.class})
|
||||
@ConditionalOnProperty(name = "redis-config.pool.hostAndPort")
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,145 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package {{ .package }}.common.response;public class FailData {
|
||||
private int code = 500;
|
||||
private String message;
|
||||
|
||||
public FailData() {
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +1,19 @@
|
||||
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() {
|
||||
this.calendar = Calendar.getInstance();
|
||||
this.dateFormat = simpleDateFormat;
|
||||
}
|
||||
|
||||
|
||||
public MyDateFormat(DateFormat dateFormat) {
|
||||
this.calendar = Calendar.getInstance();
|
||||
this.dateFormat = dateFormat;
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package {{ .package }}.common.response;
|
||||
import com.fasterxml.jackson.core.JsonParser.Feature;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class ObjectMapperFactory {
|
||||
private static final ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
public ObjectMapperFactory() {
|
||||
}
|
||||
|
||||
public static ObjectMapper getDefaultObjectMapper() {
|
||||
return objectMapper.copy();
|
||||
}
|
||||
|
||||
static {
|
||||
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).disable(SerializationFeature.FAIL_ON_EMPTY_BEANS).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).configure(Feature.ALLOW_SINGLE_QUOTES, true);
|
||||
SimpleModule bigDecimalModule = new SimpleModule();
|
||||
bigDecimalModule.addSerializer(BigDecimal.class, new ToStringSerializer());
|
||||
objectMapper.registerModule(bigDecimalModule);
|
||||
objectMapper.setDateFormat(new MyDateFormat());
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,11 @@
|
||||
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 com.vs.ex.BizException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.ConstraintViolation;
|
||||
import jakarta.validation.ConstraintViolationException;
|
||||
import jakarta.validation.Path;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.core.Ordered;
|
||||
@@ -24,65 +17,42 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
import org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver;
|
||||
|
||||
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 {
|
||||
public class ResponseJsonExceptionResolver extends AbstractHandlerExceptionResolver implements InitializingBean {
|
||||
private HttpMessageConverter messageConverter;
|
||||
|
||||
public ResponseJsonExceptionResolver() {}
|
||||
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";
|
||||
messageConverter = new MappingJackson2HttpMessageConverter(ObjectMapperFactory.getDefaultObjectMapper());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ModelAndView doResolveException(
|
||||
HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
Object handler,
|
||||
Exception ex) {
|
||||
/** web请求分页单独处理,应对antd框架 */
|
||||
protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
|
||||
FailData failData = new FailData();
|
||||
failData.setMessage(ex.getMessage());
|
||||
if (ex instanceof IgnoredException) {
|
||||
IgnoredException realEx = (IgnoredException) ex;
|
||||
failData.setCode(realEx.getErrorCode());
|
||||
failData.setData(realEx.getData());
|
||||
if (ex instanceof BizException) {
|
||||
BizException realEx = (BizException) ex;
|
||||
failData.setCode(realEx.getCode());
|
||||
failData.setMessage(realEx.getMessage());
|
||||
log.error("execute {} failed with exception", request.getRequestURL(), ex);
|
||||
} else if (ex instanceof ConstraintViolationException) {
|
||||
failData.setCode(ErrorCode.WRONG_PARAMETER);
|
||||
failData.setCode(400);
|
||||
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));
|
||||
messageConverter.write(failData, MediaType.APPLICATION_JSON, new ServletServerHttpResponse(response));
|
||||
} catch (IOException e) {
|
||||
logger.error(e.getMessage(), e);
|
||||
}
|
||||
@@ -99,9 +69,7 @@ public class ResponseJsonExceptionResolver extends AbstractHandlerExceptionResol
|
||||
for (ConstraintViolation<?> constraintViolation : e.getConstraintViolations()) {
|
||||
int i = 0;
|
||||
StringBuilder param = new StringBuilder();
|
||||
for (Iterator<Path.Node> iterator = constraintViolation.getPropertyPath().iterator();
|
||||
iterator.hasNext();
|
||||
i++) {
|
||||
for (Iterator<Path.Node> iterator = constraintViolation.getPropertyPath().iterator(); iterator.hasNext(); i++) {
|
||||
Path.Node node = iterator.next();
|
||||
if (i == 0) {
|
||||
continue;
|
||||
@@ -111,8 +79,9 @@ public class ResponseJsonExceptionResolver extends AbstractHandlerExceptionResol
|
||||
}
|
||||
param.append(node.getName());
|
||||
}
|
||||
msgList.add("参数 [ " + param + " ] " + constraintViolation.getMessage());
|
||||
msgList.add("Param [ " + param + " ] " + constraintViolation.getMessage());
|
||||
}
|
||||
return StringUtils.join(msgList.toArray(), ";");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package {{ .package }}.common.response;
|
||||
|
||||
import com.vs.common.util.rpc.pub.SuccessData;
|
||||
import com.vs.ox.common.utils.ObjectMapperFactory;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@@ -25,9 +22,7 @@ public class ResponseJsonMethodReturnValueHandler
|
||||
@Override
|
||||
public void afterPropertiesSet() {
|
||||
if (messageConverter == null) {
|
||||
messageConverter =
|
||||
new MappingJackson2HttpMessageConverter(
|
||||
ObjectMapperFactory.getDefaultObjectMapper());
|
||||
messageConverter = new MappingJackson2HttpMessageConverter(ObjectMapperFactory.getDefaultObjectMapper());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,26 +32,17 @@ public class ResponseJsonMethodReturnValueHandler
|
||||
}
|
||||
|
||||
@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);
|
||||
public void handleReturnValue(Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, NativeWebRequest webRequest) throws Exception {
|
||||
try {
|
||||
mavContainer.setRequestHandled(true);
|
||||
String customMessage = ResponseMessageHolder.getMessage();
|
||||
int code = ResponseMessageHolder.getCode();
|
||||
Object result = new SuccessData(code, returnValue, customMessage);
|
||||
|
||||
ServletServerHttpResponse response = new ServletServerHttpResponse(webRequest.getNativeResponse(HttpServletResponse.class));
|
||||
messageConverter.write(result, new MediaType(MediaType.APPLICATION_JSON, Collections.singletonMap("charset", "utf-8")), response);
|
||||
} finally {
|
||||
ResponseMessageHolder.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package {{ .package }}.common.response;
|
||||
public class ResponseMessageHolder {
|
||||
private static final ThreadLocal<String> MESSAGE_HOLDER = new InheritableThreadLocal<>();
|
||||
|
||||
public static void setMessage(String message) {
|
||||
MESSAGE_HOLDER.set(message);
|
||||
}
|
||||
|
||||
public static String getMessage() {
|
||||
return MESSAGE_HOLDER.get();
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
MESSAGE_HOLDER.remove();
|
||||
}
|
||||
|
||||
private static final ThreadLocal<Integer> CODE_HOLDER = new InheritableThreadLocal<>();
|
||||
|
||||
public static void setCode(Integer code) {
|
||||
CODE_HOLDER.set(code);
|
||||
}
|
||||
|
||||
public static Integer getCode() {
|
||||
Integer code = CODE_HOLDER.get();
|
||||
return code == null ? 200 : code;
|
||||
}
|
||||
|
||||
public static void clearCode() {
|
||||
CODE_HOLDER.remove();
|
||||
}
|
||||
|
||||
public static void setCodeAndMessage(Integer code, String message) {
|
||||
setCode(code);
|
||||
setMessage(message);
|
||||
}
|
||||
|
||||
public static void clearAll() {
|
||||
MESSAGE_HOLDER.remove();
|
||||
CODE_HOLDER.remove();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package {{ .package }}.common.response;
|
||||
public class SuccessData {
|
||||
private int code = 200;
|
||||
private Object data;
|
||||
private String message;
|
||||
|
||||
public SuccessData() {
|
||||
}
|
||||
|
||||
public SuccessData(Object data){
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public SuccessData(int code, Object data) {
|
||||
this.code = code;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public SuccessData(int code, Object data, String message) {
|
||||
this.code = code;
|
||||
this.data = data;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Object getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(Object data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
package {{ .package }}.common.response;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
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;
|
||||
@@ -13,8 +9,6 @@ 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{
|
||||
|
||||
@@ -1,15 +1,13 @@
|
||||
server.port=8082
|
||||
|
||||
mock.enabled=true
|
||||
#datasource
|
||||
{{- if eq .dbType "oracle" }}
|
||||
spring.datasource.url=jdbc:oracle:thin:@//{{ .dbHost }}:1521/ORCLCDB
|
||||
spring.datasource.url=jdbc:oracle:thin:@//{{ .dbHost }}:{{ .dbPort }}/ORCLCDB
|
||||
{{- else if eq .dbType "postgresql" }}
|
||||
spring.datasource.url=jdbc:postgresql://{{ .dbHost }}:5432/{{ .dbDatabase }}?useUnicode=true&characterEncoding=utf8&autoReconnect=true&stringtype=unspecified
|
||||
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 }/5236/SYSDBA?characterEncoding=utf-8&serverTimezone=Asia/Shanghai
|
||||
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}
|
||||
|
||||
@@ -1,72 +1,44 @@
|
||||
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
|
||||
hibernate.dialect=org.hibernate.dialect.MySQLDialect
|
||||
#mysql | oracle | postgresql
|
||||
db.type=mysql
|
||||
{{- else if eq .dbType "postgresql" }}
|
||||
spring.datasource.driver-class-name=org.postgresql.Driver
|
||||
vs.sqlmapper.dialect=postgresql
|
||||
#mysql | oracle | postgresql
|
||||
db.type=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.OracleDialect
|
||||
vs.sqlmapper.dialect=oracle
|
||||
hibernate.dialect=org.hibernate.dialect.Oracle10gDialect
|
||||
#mysql | oracle | postgresql
|
||||
db.type=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
|
||||
#mysql | oracle | postgresql
|
||||
db.type=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=
|
||||
db.basetable.create=true
|
||||
#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
|
||||
spring.autoconfigure.exclude=org.redisson.spring.starter.RedissonAutoConfiguration
|
||||
#redis
|
||||
#spring.redis.host=${REDIS_HOST:localhost}
|
||||
#spring.redis.port=6379
|
||||
#spring.redis.timeout=3000
|
||||
|
||||
#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
|
||||
|
||||
11
template/facade/pom.xml
Normal file
11
template/facade/pom.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?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>${revision}</version>
|
||||
</parent>
|
||||
<artifactId>{{ .artifactId }}-facade</artifactId>
|
||||
</project>
|
||||
@@ -115,11 +115,11 @@
|
||||
<artifactId>aspectjrt</artifactId>
|
||||
<version>1.9.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
<version>3.3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.redisson</groupId>
|
||||
<artifactId>redisson-spring-boot-starter</artifactId>
|
||||
<version>3.23.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
@@ -287,6 +287,8 @@
|
||||
<modules>
|
||||
<module>entrance</module>
|
||||
<module>common</module>
|
||||
<module>public_service</module>
|
||||
<module>facade</module>
|
||||
</modules>
|
||||
</project>
|
||||
|
||||
|
||||
11
template/public_service/pom.xml
Normal file
11
template/public_service/pom.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?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>${revision}</version>
|
||||
</parent>
|
||||
<artifactId>{{ .artifactId }}-public-service</artifactId>
|
||||
</project>
|
||||
Reference in New Issue
Block a user