Commit 7af640e7 authored by 张永's avatar 张永

11

parent befc2d8f
......@@ -109,6 +109,11 @@
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
......@@ -126,6 +131,7 @@
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>9.4.0.jre8</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
......
package com.egolm.shop;
import java.util.TimeZone;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableAsync(proxyTargetClass=true)
......@@ -17,12 +23,19 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@SpringBootApplication
@EnableTransactionManagement
public class ShopApplication {
private static Logger logger = LoggerFactory.getLogger(ShopApplication.class);
private static ApplicationContext applicationContext;
public static void main(String[] args) {
try {
System.setProperty("java.io.tmpdir", "temp");
applicationContext = SpringApplication.run(ShopApplication.class, args);
}catch(Exception e) {
logger.info("docker 容器中运行。。。。");
System.setProperty("java.io.tmpdir", "/data/temp"); //容器内使用这种
}finally {
TimeZone.setDefault(TimeZone.getTimeZone("GMT+8"));
applicationContext = SpringApplication.run(ApplicationContext.class, args);
}
}
public static ApplicationContext getApplicationContext() {
......@@ -41,5 +54,4 @@ public class ShopApplication {
public static <T> T getBean(String name, Class<T> clazz){
return getApplicationContext().getBean(name, clazz);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment