diff --git a/pom.xml b/pom.xml
index 8dda94c..470051a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -61,6 +61,13 @@
20250517
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+ 2025.0.0.0-preview
+
+
org.springframework.boot
spring-boot-starter-test
diff --git a/src/main/java/com/ljc42/product/Controller/ProductController.java b/src/main/java/com/ljc42/product/Controller/ProductController.java
index 627eb21..8acc851 100644
--- a/src/main/java/com/ljc42/product/Controller/ProductController.java
+++ b/src/main/java/com/ljc42/product/Controller/ProductController.java
@@ -6,6 +6,8 @@ import com.ljc42.product.Exceptions.ProductExitsException;
import com.ljc42.product.Exceptions.ProductNotFoundException;
import com.ljc42.product.Service.ProductService;
import org.json.JSONObject;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@@ -14,14 +16,23 @@ import java.util.Map;
import java.util.Objects;
@RestController
+@RefreshScope
public class ProductController {
private final ProductService productService;
+ @Value(value = "${product.service.welcome-message}")
+ private String welcomeMessage;
+
public ProductController(ProductService productService) {
this.productService = productService;
}
+ @GetMapping("/api/v1/hello")
+ public ResponseEntity hello() {
+ return new ResponseEntity<>(welcomeMessage, HttpStatus.OK);
+ }
+
@GetMapping("/api/v1/product/{name}")
public ResponseEntity getProducts(@PathVariable String name) {
try {
diff --git a/src/main/java/com/ljc42/product/RocketMQConfig.java b/src/main/java/com/ljc42/product/RocketMQConfig.java
deleted file mode 100644
index c082fde..0000000
--- a/src/main/java/com/ljc42/product/RocketMQConfig.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.ljc42.product;
-
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class RocketMQConfig {
-
-}
diff --git a/src/main/java/com/ljc42/product/Service/ProductService.java b/src/main/java/com/ljc42/product/Service/ProductService.java
index 39e275f..65333b5 100644
--- a/src/main/java/com/ljc42/product/Service/ProductService.java
+++ b/src/main/java/com/ljc42/product/Service/ProductService.java
@@ -32,8 +32,8 @@ public class ProductService {
} else {
redisTemplate.delete(productDTO.getName());
this.productRepository.save(ProductMapper.DTOtoProduct(productDTO));
- rocketMQTemplate.getProducer().setSendMsgTimeout(10000);
- rocketMQTemplate.convertAndSend("PRODUCT_CREATE_TOPIC", productDTO.getName());
+// rocketMQTemplate.getProducer().setSendMsgTimeout(10000);
+// rocketMQTemplate.convertAndSend("PRODUCT_CREATE_TOPIC", productDTO.getName());
return productDTO;
}
}
diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties
index 983352a..ddc8b3c 100644
--- a/src/main/resources/application.properties
+++ b/src/main/resources/application.properties
@@ -11,4 +11,6 @@ spring.redis.host=localhost
spring.redis.port=6379
rocketmq.name-server=localhost:9876
-rocketmq.producer.group=my_producer_group
\ No newline at end of file
+rocketmq.producer.group=my_producer_group
+
+spring.config.import=nacos:nacosConfig.yaml
\ No newline at end of file
diff --git a/src/main/resources/nacosConfig.yaml b/src/main/resources/nacosConfig.yaml
new file mode 100644
index 0000000..7a62506
--- /dev/null
+++ b/src/main/resources/nacosConfig.yaml
@@ -0,0 +1,7 @@
+spring:
+ cloud:
+ nacos:
+ serverAddr: 10.10.2.71:8848
+ config:
+ import:
+ - nacos:demo.properties?refreshEnabled=true
\ No newline at end of file