修复restful负载均衡问题

This commit is contained in:
tanghc
2021-02-02 14:00:50 +08:00
parent 8d071e2ac3
commit d642a4f9c6
7 changed files with 68 additions and 14 deletions

View File

@@ -4,6 +4,8 @@ import com.gitee.sop.servercommon.util.UploadUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -25,6 +27,8 @@ import java.util.Collection;
@Api(tags = "食物接口")
public class Example1008_RestfulController {
@Autowired
private Environment environment;
// http://localhost:8081/rest/story-service/food/getFoodById?id=1 网关入口
// http://localhost:2222/food/getFoodById/?id=12 本地入口
@@ -33,7 +37,7 @@ public class Example1008_RestfulController {
public Food getFoodById(Integer id) {
Food food = new Food();
food.setId(id);
food.setName("香蕉");
food.setName("香蕉, " + environment.getProperty("server.port"));
food.setPrice(new BigDecimal(20.00));
return food;
}

View File

@@ -1,6 +1,9 @@
server.port=2222
spring.application.name=story-service
register.url=127.0.0.1:8848
# 注册中心
# \u6CE8\u518C\u4E2D\u5FC3
spring.cloud.nacos.discovery.server-addr=${register.url}
# \u4E0A\u4F20\u6587\u4EF6\u6700\u5927\u503C
spring.servlet.multipart.max-file-size=20MB
spring.servlet.multipart.max-request-size=20MB