package com.zt.life; import cn.hutool.core.io.FileUtil; import com.zt.modules.workflow.service.WorkflowService; import org.mybatis.spring.annotation.MapperScan; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.cache.annotation.EnableCaching; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.data.redis.connection.RedisConnectionFactory; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.serializer.StringRedisSerializer; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; import java.io.File; /** * @author hehz */ @MapperScan("com.zt.**.dao") @ComponentScan(basePackages = {"com.zt.**"}) @SpringBootApplication(exclude = { // org.activiti.spring.boot.SecurityAutoConfiguration.class, org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration.class}) @EnableCaching @EnableAsync @EnableScheduling public class AdminApplication extends SpringBootServletInitializer { @Value("${zt.oss.local-path}") private String localPath; @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(AdminApplication.class); } @Autowired private WorkflowService workflowService; public static void main(String[] args) { SpringApplication.run(AdminApplication.class, args); } @Bean public ConfigurableServletWebServerFactory webServerFactory() { TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); factory.addConnectorCustomizers((TomcatConnectorCustomizer) connector -> connector.setProperty("relaxedQueryChars", "|{}[]\\")); return factory; } // @Scheduled(cron = "0 0 3 * * ?") //每天3点执行 // public void timerListener() throws ParseException { ///* projectService.dropTemporaryTable(); // projectService.updateHasLifeData(); // this.deleteTempFile();*/ // } private void deleteTempFile() { String tempUploadDir = localPath + File.separator + "TEMP_UPLOAD"; FileUtil.del(tempUploadDir); tempUploadDir = localPath + File.separator + "svg"; FileUtil.del(tempUploadDir); } @Autowired private RedisConnectionFactory redisConnectionFactory; @Bean public RedisTemplate redisTemplate() { RedisTemplate redisTemplate = new RedisTemplate<>(); // 暂时先设置key和value的序列化都是字符串 redisTemplate.setKeySerializer(new StringRedisSerializer()); redisTemplate.setValueSerializer(new StringRedisSerializer()); redisTemplate.setHashKeySerializer(new StringRedisSerializer()); redisTemplate.setHashValueSerializer(new StringRedisSerializer()); redisTemplate.setConnectionFactory(redisConnectionFactory); return redisTemplate; } }