You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.1 KiB

3 years ago
package com.qs.serve;
import com.qs.serve.common.config.DevEnvironmentConfig;
import com.qs.serve.task.TbsTask;
import org.springframework.beans.factory.annotation.Autowired;
2 years ago
import org.springframework.beans.factory.annotation.Value;
3 years ago
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
2 years ago
import org.springframework.core.env.Environment;
3 years ago
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.stereotype.Indexed;
3 years ago
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.annotation.PostConstruct;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import java.util.TimeZone;
/**
* @author YenHex
* @since 2022/2/24
*/
@Indexed
3 years ago
@EnableAsync
@EnableScheduling
@EnableTransactionManagement
@EnableCaching
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
2 years ago
@Value("${project.dev}")
String dev;
3 years ago
public static void main(String[] args) {
long start = System.currentTimeMillis();
3 years ago
SpringApplication.run(Application.class,args);
long end = System.currentTimeMillis();
double diff = (end-start)/1000.0;
System.out.println("启动时间:"+diff);
3 years ago
}
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
super.onStartup(servletContext);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(Application.class);
}
@PostConstruct
void started() {
TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
2 years ago
DevEnvironmentConfig.openDevEnv(dev.equals("true"));
3 years ago
}
}