FengChaoYu 6 meses atrás
pai
commit
b1972f7543

+ 8 - 1
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/config/MulitpartConfig.java

@@ -1,5 +1,6 @@
 package com.gree.mall.miniapp.config;
 
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.web.servlet.MultipartConfigFactory;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -9,13 +10,19 @@ import javax.servlet.MultipartConfigElement;
 @Configuration
 public class MulitpartConfig {
 
+    @Value("${spring.profiles.active}")
+    private String env;
     /**
      * 文件上传临时路径
      */
     @Bean
     MultipartConfigElement multipartConfigElement() {
         MultipartConfigFactory factory = new MultipartConfigFactory();
-        factory.setLocation("/app");
+        if (env.equals("prd")) {
+            factory.setLocation("/home/jsmapp");
+        } else {
+            factory.setLocation("/app");
+        }
         return factory.createMultipartConfig();
     }
 

+ 10 - 1
mall-server-api/src/main/java/com/gree/mall/manager/config/MulitpartConfig.java

@@ -1,5 +1,6 @@
 package com.gree.mall.manager.config;
 
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.web.servlet.MultipartConfigFactory;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -9,13 +10,21 @@ import javax.servlet.MultipartConfigElement;
 @Configuration
 public class MulitpartConfig {
 
+
+    @Value("${spring.profiles.active}")
+    private String env;
     /**
      * 文件上传临时路径
      */
     @Bean
     MultipartConfigElement multipartConfigElement() {
         MultipartConfigFactory factory = new MultipartConfigFactory();
-        factory.setLocation("/app");
+        if (env.equals("prd")) {
+            factory.setLocation("/home/jsmapp");
+        } else {
+            factory.setLocation("/app");
+        }
+
         return factory.createMultipartConfig();
     }