| @@ -1,8 +1,10 @@ | |||||
| package com.iformall; | package com.iformall; | ||||
| import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | ||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| 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.scheduling.annotation.EnableAsync; | import org.springframework.scheduling.annotation.EnableAsync; | ||||
| import springfox.documentation.swagger2.annotations.EnableSwagger2; | import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||||
| import tk.mybatis.spring.annotation.MapperScan; | import tk.mybatis.spring.annotation.MapperScan; | ||||
| @@ -18,6 +20,14 @@ import tk.mybatis.spring.annotation.MapperScan; | |||||
| @EnableAsync | @EnableAsync | ||||
| public class UserApplication { | public class UserApplication { | ||||
| @Value("${fm.exception}") | |||||
| private boolean fmException; | |||||
| @Bean | |||||
| public boolean isFmException() { | |||||
| return fmException; | |||||
| } | |||||
| public static void main(String[] args) { | public static void main(String[] args) { | ||||
| SpringApplication.run(UserApplication.class, args); | SpringApplication.run(UserApplication.class, args); | ||||
| } | } | ||||
| @@ -89,6 +89,8 @@ public class HomeController extends BaseController { | |||||
| return new ResultData(ErrorCode.KAPCHA_NOT_VALID.getCode(), e.getMessage()); | return new ResultData(ErrorCode.KAPCHA_NOT_VALID.getCode(), e.getMessage()); | ||||
| } | } | ||||
| Double.parseDouble("askhahsf"); | |||||
| ResultData data = new ResultData(); | ResultData data = new ResultData(); | ||||
| if (StringUtils.isBlank(user.getUsername()) || StringUtils.isBlank(user.getPassword())) { | if (StringUtils.isBlank(user.getUsername()) || StringUtils.isBlank(user.getPassword())) { | ||||
| @@ -39,6 +39,9 @@ spring: | |||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 10 | min-idle: 10 | ||||
| fm: | |||||
| exception: false | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| tk.mybatis: debug | tk.mybatis: debug | ||||
| @@ -35,6 +35,10 @@ spring: | |||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 0 | min-idle: 0 | ||||
| fm: | |||||
| exception: true | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| tk.mybatis: debug | tk.mybatis: debug | ||||
| @@ -36,6 +36,9 @@ spring: | |||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 0 | min-idle: 0 | ||||
| fm: | |||||
| exception: true | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| tk.mybatis: debug | tk.mybatis: debug | ||||
| @@ -1,8 +1,10 @@ | |||||
| package com.iformall; | package com.iformall; | ||||
| import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | ||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| 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 tk.mybatis.spring.annotation.MapperScan; | import tk.mybatis.spring.annotation.MapperScan; | ||||
| /** | /** | ||||
| @@ -14,6 +16,15 @@ import tk.mybatis.spring.annotation.MapperScan; | |||||
| @EnableEncryptableProperties | @EnableEncryptableProperties | ||||
| public class BApplication { | public class BApplication { | ||||
| @Value("${fm.exception}") | |||||
| private boolean fmException; | |||||
| @Bean | |||||
| public boolean isFmException() { | |||||
| return fmException; | |||||
| } | |||||
| public static void main(String[] args) { | public static void main(String[] args) { | ||||
| SpringApplication.run(BApplication.class, args); | SpringApplication.run(BApplication.class, args); | ||||
| } | } | ||||
| @@ -38,6 +38,9 @@ spring: | |||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 0 | min-idle: 0 | ||||
| fm: | |||||
| exception: false | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| tk.mybatis: debug | tk.mybatis: debug | ||||
| @@ -35,6 +35,9 @@ spring: | |||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 0 | min-idle: 0 | ||||
| fm: | |||||
| exception: true | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| tk.mybatis: debug | tk.mybatis: debug | ||||
| @@ -35,6 +35,9 @@ spring: | |||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 0 | min-idle: 0 | ||||
| fm: | |||||
| exception: true | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| tk.mybatis: debug | tk.mybatis: debug | ||||
| @@ -1,8 +1,10 @@ | |||||
| package com.iformall; | package com.iformall; | ||||
| import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | ||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| 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 tk.mybatis.spring.annotation.MapperScan; | import tk.mybatis.spring.annotation.MapperScan; | ||||
| /** | /** | ||||
| @@ -14,6 +16,15 @@ import tk.mybatis.spring.annotation.MapperScan; | |||||
| @EnableEncryptableProperties | @EnableEncryptableProperties | ||||
| public class CApplication { | public class CApplication { | ||||
| @Value("${fm.exception}") | |||||
| private boolean fmException; | |||||
| @Bean | |||||
| public boolean isFmException() { | |||||
| return fmException; | |||||
| } | |||||
| public static void main(String[] args) { | public static void main(String[] args) { | ||||
| SpringApplication.run(CApplication.class, args); | SpringApplication.run(CApplication.class, args); | ||||
| } | } | ||||
| @@ -37,6 +37,9 @@ spring: | |||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 0 | min-idle: 0 | ||||
| fm: | |||||
| exception: false | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| tk.mybatis: debug | tk.mybatis: debug | ||||
| @@ -35,6 +35,9 @@ spring: | |||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 0 | min-idle: 0 | ||||
| fm: | |||||
| exception: true | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| tk.mybatis: debug | tk.mybatis: debug | ||||
| @@ -35,6 +35,9 @@ spring: | |||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 0 | min-idle: 0 | ||||
| fm: | |||||
| exception: true | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| tk.mybatis: debug | tk.mybatis: debug | ||||
| @@ -1,8 +1,10 @@ | |||||
| package com.iformall; | package com.iformall; | ||||
| import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | import com.ulisesbocchio.jasyptspringboot.annotation.EnableEncryptableProperties; | ||||
| import org.springframework.beans.factory.annotation.Value; | |||||
| 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 springfox.documentation.swagger2.annotations.EnableSwagger2; | import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||||
| import tk.mybatis.spring.annotation.MapperScan; | import tk.mybatis.spring.annotation.MapperScan; | ||||
| @@ -16,6 +18,15 @@ import tk.mybatis.spring.annotation.MapperScan; | |||||
| @EnableEncryptableProperties | @EnableEncryptableProperties | ||||
| public class ScheduleApplication { | public class ScheduleApplication { | ||||
| @Value("${fm.exception}") | |||||
| private boolean fmException; | |||||
| @Bean | |||||
| public boolean isFmException() { | |||||
| return fmException; | |||||
| } | |||||
| public static void main(String[] args) { | public static void main(String[] args) { | ||||
| SpringApplication.run(ScheduleApplication.class, args); | SpringApplication.run(ScheduleApplication.class, args); | ||||
| } | } | ||||
| @@ -39,6 +39,9 @@ spring: | |||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 10 | min-idle: 10 | ||||
| fm: | |||||
| exception: false | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| tk.mybatis: debug | tk.mybatis: debug | ||||
| @@ -36,6 +36,9 @@ spring: | |||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 0 | min-idle: 0 | ||||
| fm: | |||||
| exception: true | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| tk.mybatis: debug | tk.mybatis: debug | ||||
| @@ -36,6 +36,9 @@ spring: | |||||
| max-wait: -1 | max-wait: -1 | ||||
| min-idle: 0 | min-idle: 0 | ||||
| fm: | |||||
| exception: true | |||||
| logging: | logging: | ||||
| level: | level: | ||||
| tk.mybatis: debug | tk.mybatis: debug | ||||
| @@ -22,6 +22,9 @@ public class GlobalDefultExceptionHandler { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | private final Logger logger = LoggerFactory.getLogger(this.getClass()); | ||||
| @Autowired | |||||
| private boolean isFmException; | |||||
| @Autowired | @Autowired | ||||
| private MailService mailService; | private MailService mailService; | ||||
| @@ -30,21 +33,24 @@ public class GlobalDefultExceptionHandler { | |||||
| public String defultExcepitonHandler(HttpServletRequest request, Exception e) { | public String defultExcepitonHandler(HttpServletRequest request, Exception e) { | ||||
| log(e, request); | log(e, request); | ||||
| StringWriter sw = new StringWriter(); | |||||
| PrintWriter pw = new PrintWriter(sw); | |||||
| e.printStackTrace(pw); | |||||
| if(isFmException) { | |||||
| StringWriter sw = new StringWriter(); | |||||
| PrintWriter pw = new PrintWriter(sw); | |||||
| e.printStackTrace(pw); | |||||
| SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式 | |||||
| SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式 | |||||
| StringBuilder sb = new StringBuilder(); | |||||
| sb.append(df.format(new Date())); | |||||
| sb.append("\n"); | |||||
| sb.append(sw.toString()); | |||||
| StringBuilder sb = new StringBuilder(); | |||||
| sb.append(df.format(new Date())); | |||||
| sb.append("\n"); | |||||
| sb.append(sw.toString()); | |||||
| String[] receivers = new String[] {"hupeng@iformall.com", "wuguoqiang@iformall.com", "gongbiao@iformall.com"}; | |||||
| String[] receivers = new String[] {"hupeng@iformall.com", "wuguoqiang@iformall.com", "gongbiao@iformall.com"}; | |||||
| //发送邮件 | |||||
| mailService.sendSimpleMail(receivers, "请求地址:" + request.getRequestURL() + "异常", sb.toString()); | |||||
| } | |||||
| //发送邮件 | |||||
| mailService.sendSimpleMail(receivers, "请求地址:" + request.getRequestURL() + "异常", sb.toString()); | |||||
| return "发生异常"; | return "发生异常"; | ||||
| } | } | ||||