fix: 修改编译不过的问题

This commit is contained in:
2024-11-20 13:59:02 +08:00
parent 374c5758da
commit a429c73924
8 changed files with 56 additions and 24 deletions

View File

@@ -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);
}
}

View File

@@ -1,5 +1,6 @@
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;

View File

@@ -1,5 +1,6 @@
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;

View File

@@ -1,12 +1,6 @@
package {{ .package }}.common.response;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.vs.ox.starters.web.autoconfig.bind.JsonRequestParamHandlerMethodArgumentResolver;
import com.vs.ox.starters.web.autoconfig.bind.MyDateFormat;
import com.vs.ox.starters.web.autoconfig.interceptor.LoginCheckInterceptor;
import com.vs.ox.starters.web.autoconfig.interceptor.LoginTokenInterceptor;
import com.vs.ox.starters.web.autoconfig.resolver.ResponseJsonExceptionResolver;
import com.vs.ox.starters.web.autoconfig.resolver.ResponseJsonMethodReturnValueHandler;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
@@ -33,7 +27,7 @@ import java.util.Iterator;
import java.util.List;
@Configuration
@ComponentScan("{{ .package }}")
@ComponentScan("com.vs.ox")
public class
WebMvcConfiguration extends WebMvcConfigurerAdapter implements ApplicationContextAware {
RequestMappingHandlerAdapter requestMappingHandlerAdapter;
@@ -76,19 +70,6 @@ WebMvcConfiguration extends WebMvcConfigurerAdapter implements ApplicationContex
returnValueHandlers.add(responseJsonMethodReturnValueHandler);
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new LoginTokenInterceptor());
registry.addInterceptor(new LoginCheckInterceptor());
}
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
argumentResolvers.add(new JsonRequestParamHandlerMethodArgumentResolver());
super.addArgumentResolvers(argumentResolvers);
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
@@ -101,7 +82,7 @@ WebMvcConfiguration extends WebMvcConfigurerAdapter implements ApplicationContex
public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
ObjectMapper mapper = jackson2ObjectMapperBuilder.build();
DateFormat dateFormat = mapper.getDateFormat();
mapper.setDateFormat(new MyDateFormat(dateFormat));
mapper.setDateFormat(new com.maquan_ceshi.maquan_ceshi.common.response.MyDateFormat(dateFormat));
MappingJackson2HttpMessageConverter mappingJsonpHttpMessageConverter = new MappingJackson2HttpMessageConverter(mapper);
return mappingJsonpHttpMessageConverter;
}

View File

@@ -23,6 +23,7 @@ import org.springframework.context.annotation.Import;
@EnableVSReplayConfiguration
@EnableVSMockConfiguration
@EnableVSMockExpress
@MapperScan("自定义mapper包")
public class AppApplication{
// @Bean(name = "stackContextInvokeRecorder")

View File

@@ -13,7 +13,7 @@ mock.enabled=true
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 "oracle" }}
{{- else if eq .dbType "mysql" }}
spring.datasource.url=jdbc:{{ .dbType }}://{{ .dbHost }}:{{ .dbPort }}/{{ .dbDatabase }}?characterEncoding=utf-8&serverTimezone=Asia/Shanghai
{{- end }}
spring.datasource.username={{ .dbUsername }}

View File

@@ -12,7 +12,7 @@ base.package={{.groupId}}
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 "oracle" }}
{{- else if eq .dbType "mysql" }}
spring.datasource.url=jdbc:{{ .dbType }}://{{ .dbHost }}:{{ .dbPort }}/{{ .dbDatabase }}?characterEncoding=utf-8&serverTimezone=Asia/Shanghai
{{- end }}
spring.datasource.username={{ .dbUsername }}

View File

@@ -12,7 +12,7 @@ base.package={{.groupId}}
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 "oracle" }}
{{- else if eq .dbType "mysql" }}
spring.datasource.url=jdbc:{{ .dbType }}://{{ .dbHost }}:{{ .dbPort }}/{{ .dbDatabase }}?characterEncoding=utf-8&serverTimezone=Asia/Shanghai
{{- end }}
spring.datasource.username={{ .dbUsername }}