dateFormat

This commit is contained in:
oyo
2025-12-14 16:24:34 +08:00
parent 8d52e83a21
commit dd955bb0a8
5 changed files with 9 additions and 24 deletions

View File

@@ -6,10 +6,15 @@ import java.util.Date;
public class MyDateFormat extends DateFormat { public class MyDateFormat extends DateFormat {
private static final long serialVersionUID = -4580955831439573829L; private static final long serialVersionUID = -4580955831439573829L;
private static final String customDateFormat = "yyyy-MM-dd HH:mm:ss";
private DateFormat dateFormat; private DateFormat dateFormat;
private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
public MyDateFormat() {
this.calendar = Calendar.getInstance();
this.dateFormat = simpleDateFormat;
}
public MyDateFormat(DateFormat dateFormat) { public MyDateFormat(DateFormat dateFormat) {
this.calendar = Calendar.getInstance(); this.calendar = Calendar.getInstance();
this.dateFormat = dateFormat; this.dateFormat = dateFormat;

View File

@@ -1,5 +1,6 @@
package {{ .package }}.common.response; package {{ .package }}.common.response;
import {{ .package }}.common.utils.ObjectMapperFactory;
import com.vs.ex.BizException; import com.vs.ex.BizException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@@ -38,17 +39,6 @@ public class ResponseJsonExceptionResolver extends AbstractHandlerExceptionResol
} }
} }
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 @Override
protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) { protected ModelAndView doResolveException(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) {
FailData failData = new FailData(); FailData failData = new FailData();

View File

@@ -1,5 +1,6 @@
package {{ .package }}.common.response; package {{ .package }}.common.response;
import {{ .package }}.common.utils.ObjectMapperFactory;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.MethodParameter; import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;

View File

@@ -25,7 +25,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
@Configuration @Configuration
@ComponentScan("com.vs.ox") @ComponentScan("com.vs")
public class public class
WebMvcConfiguration extends WebMvcConfigurerAdapter implements ApplicationContextAware { WebMvcConfiguration extends WebMvcConfigurerAdapter implements ApplicationContextAware {
RequestMappingHandlerAdapter requestMappingHandlerAdapter; RequestMappingHandlerAdapter requestMappingHandlerAdapter;
@@ -37,9 +37,7 @@ WebMvcConfiguration extends WebMvcConfigurerAdapter implements ApplicationContex
List<HandlerMethodReturnValueHandler> newProcessors = new ArrayList<>(); List<HandlerMethodReturnValueHandler> newProcessors = new ArrayList<>();
while (iterator.hasNext()) { while (iterator.hasNext()) {
HandlerMethodReturnValueHandler next = iterator.next(); HandlerMethodReturnValueHandler next = iterator.next();
//为了能在controller中直接返回map不被默认的MapMethodProcessor拦截
if (next instanceof MapMethodProcessor || if (next instanceof MapMethodProcessor ||
//为了能在controller中直接返回String不被默认的ViewNameMethodReturnValueHandler拦截
next instanceof ViewNameMethodReturnValueHandler) { next instanceof ViewNameMethodReturnValueHandler) {
continue; continue;
} else { } else {

View File

@@ -1,27 +1,18 @@
package {{ .package }}.entrance.web; 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.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication(scanBasePackages = {"{{.groupId}}", "com.vs"}) @SpringBootApplication(scanBasePackages = {"{{.groupId}}", "com.vs"})
@VSDaoBeanScan(basePackages = {"com.vs","{{.groupId}}"})
@Import(DataSourceConfig.class)
@MapperScan("{{.groupId}}.**.persist.mapper.mybatis") @MapperScan("{{.groupId}}.**.persist.mapper.mybatis")
@EnableScheduling @EnableScheduling
public class AppApplication{ public class AppApplication{
public static void main(String[] args) { public static void main(String[] args) {
SpringApplication application = new SpringApplication(AppApplication.class); SpringApplication application = new SpringApplication(AppApplication.class);
application.addInitializers(new TocoAgentInitializer());
application.run(args); application.run(args);
} }
} }