Quellcode durchsuchen

引入bootstrap依赖 修改工具类支持nacos配置立即生效

penghao vor 3 Monaten
Ursprung
Commit
b9faf005ee

+ 5 - 0
alien-api/pom.xml

@@ -147,6 +147,11 @@
             <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-bootstrap</artifactId>
+        </dependency>
+
     </dependencies>
 
     <build>

+ 5 - 0
alien-gateway/pom.xml

@@ -188,6 +188,11 @@
 
         <dependency>
             <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-bootstrap</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-starter-openfeign</artifactId>
         </dependency>
 

+ 5 - 0
alien-job/pom.xml

@@ -84,6 +84,11 @@
         </dependency>
 
         <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-bootstrap</artifactId>
+        </dependency>
+
+        <dependency>
             <groupId>com.baomidou</groupId>
             <artifactId>mybatis-plus-boot-starter</artifactId>
         </dependency>

+ 5 - 0
alien-lawyer/pom.xml

@@ -237,6 +237,11 @@
         </dependency>
 
         <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-bootstrap</artifactId>
+        </dependency>
+
+        <dependency>
             <groupId>shop.alien</groupId>
             <artifactId>alien-entity</artifactId>
             <version>1.0.0</version>

+ 5 - 0
alien-second/pom.xml

@@ -238,6 +238,11 @@
             <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-bootstrap</artifactId>
+        </dependency>
+
         <!-- openfeign -->
         <dependency>
             <groupId>org.springframework.cloud</groupId>

+ 5 - 0
alien-store-platform/pom.xml

@@ -242,6 +242,11 @@
         </dependency>
 
         <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-bootstrap</artifactId>
+        </dependency>
+
+        <dependency>
             <groupId>shop.alien</groupId>
             <artifactId>alien-entity</artifactId>
             <version>1.0.0</version>

+ 5 - 0
alien-store/pom.xml

@@ -242,6 +242,11 @@
         </dependency>
 
         <dependency>
+            <groupId>org.springframework.cloud</groupId>
+            <artifactId>spring-cloud-starter-bootstrap</artifactId>
+        </dependency>
+
+        <dependency>
             <groupId>shop.alien</groupId>
             <artifactId>alien-entity</artifactId>
             <version>1.0.0</version>

+ 2 - 0
alien-store/src/main/java/shop/alien/store/config/ElasticSearchComponent.java

@@ -27,6 +27,7 @@ import org.elasticsearch.search.SearchHits;
 import org.elasticsearch.search.builder.SearchSourceBuilder;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.PostConstruct;
@@ -41,6 +42,7 @@ import java.util.UUID;
  */
 @Slf4j
 @Component
+@RefreshScope
 public class ElasticSearchComponent {
 
     @Autowired

+ 2 - 0
alien-store/src/main/java/shop/alien/store/config/GaoDeMapUtil.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.stereotype.Component;
 import shop.alien.entity.store.EssentialCityCode;
 import shop.alien.mapper.EssentialCityCodeMapper;
@@ -29,6 +30,7 @@ import java.util.Map;
  */
 @Slf4j
 @Component
+@RefreshScope
 @RequiredArgsConstructor
 public class GaoDeMapUtil {
 

+ 2 - 0
alien-store/src/main/java/shop/alien/store/util/FileUploadUtil.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
 import org.springframework.web.multipart.MultipartRequest;
@@ -25,6 +26,7 @@ import java.util.*;
  */
 @Slf4j
 @Component
+@RefreshScope
 @RequiredArgsConstructor
 public class FileUploadUtil {
 

+ 2 - 0
alien-store/src/main/java/shop/alien/store/util/ai/AiAuthTokenUtil.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.http.*;
 import org.springframework.stereotype.Component;
 import org.springframework.util.LinkedMultiValueMap;
@@ -16,6 +17,7 @@ import org.springframework.web.client.RestTemplate;
  */
 @Slf4j
 @Component
+@RefreshScope
 @RequiredArgsConstructor
 public class AiAuthTokenUtil {
 

+ 2 - 0
alien-store/src/main/java/shop/alien/store/util/ai/AiContentModerationUtil.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpStatus;
@@ -24,6 +25,7 @@ import java.util.ArrayList;
  */
 @Slf4j
 @Component
+@RefreshScope
 @RequiredArgsConstructor
 public class AiContentModerationUtil {
 

+ 2 - 0
alien-store/src/main/java/shop/alien/store/util/ai/AiFeedbackAssignUtils.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.core.io.ByteArrayResource;
 import org.springframework.http.*;
 import org.springframework.stereotype.Component;
@@ -21,6 +22,7 @@ import java.util.Map;
 
 @Slf4j
 @Component
+@RefreshScope
 @RequiredArgsConstructor
 public class AiFeedbackAssignUtils {
 

+ 2 - 0
alien-store/src/main/java/shop/alien/store/util/ai/AiGetPriceUtil.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.http.*;
 import org.springframework.http.client.SimpleClientHttpRequestFactory;
 import org.springframework.stereotype.Component;
@@ -24,6 +25,7 @@ import java.util.Map;
  */
 @Slf4j
 @Component
+@RefreshScope
 @RequiredArgsConstructor
 public class AiGetPriceUtil {
 

+ 2 - 0
alien-store/src/main/java/shop/alien/store/util/ai/AiImageColorExtractUtil.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.http.*;
 import org.springframework.stereotype.Component;
 import org.springframework.util.StringUtils;
@@ -22,6 +23,7 @@ import java.util.Map;
  */
 @Slf4j
 @Component
+@RefreshScope
 @RequiredArgsConstructor
 public class AiImageColorExtractUtil {
 

+ 2 - 0
alien-store/src/main/java/shop/alien/store/util/ai/AiVideoModerationUtil.java

@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONObject;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpHeaders;
 import org.springframework.http.HttpStatus;
@@ -24,6 +25,7 @@ import java.util.List;
  */
 @Slf4j
 @Component
+@RefreshScope
 @RequiredArgsConstructor
 public class AiVideoModerationUtil {
 

+ 2 - 0
alien-store/src/main/java/shop/alien/store/util/ali/AliApi.java

@@ -15,6 +15,7 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
 import shop.alien.entity.result.R;
@@ -42,6 +43,7 @@ import java.util.Map;
  */
 @Slf4j
 @Component
+@RefreshScope
 @RequiredArgsConstructor
 public class AliApi {
 

+ 2 - 0
alien-store/src/main/java/shop/alien/store/util/ali/AliSms.java

@@ -8,6 +8,7 @@ import com.aliyun.teautil.models.RuntimeOptions;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.stereotype.Component;
 import shop.alien.entity.store.StoreVerificationCode;
 import shop.alien.mapper.StoreVerificationCodeMapper;
@@ -26,6 +27,7 @@ import java.util.Date;
  */
 @Slf4j
 @Component
+@RefreshScope
 @RequiredArgsConstructor
 public class AliSms {
     private final BaseRedisService baseRedisService;

+ 2 - 0
alien-util/src/main/java/shop/alien/util/ali/AliOSSUtil.java

@@ -9,6 +9,7 @@ import com.aliyun.oss.model.PutObjectResult;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
 import org.springframework.stereotype.Component;
 import org.springframework.web.multipart.MultipartFile;
 import shop.alien.util.file.FileUtil;
@@ -24,6 +25,7 @@ import java.io.File;
  */
 @Slf4j
 @Component
+@RefreshScope
 public class AliOSSUtil {
 
     @Value("${ali.oss.accessKeyId}")

+ 6 - 0
pom.xml

@@ -81,6 +81,12 @@
             </dependency>
 
             <dependency>
+                <groupId>org.springframework.cloud</groupId>
+                <artifactId>spring-cloud-starter-bootstrap</artifactId>
+                <version>3.0.4</version>
+            </dependency>
+
+            <dependency>
                 <groupId>org.redisson</groupId>
                 <artifactId>redisson-spring-boot-starter</artifactId>
                 <version>3.17.7</version>