This repository has been archived by the owner on Sep 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
90 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
- 基于Zookeeper实现的分布式锁 | ||
- 分布式ID(基于Leaf的Segment模式) | ||
- 分布式事务(使用RocketMQ实现最终一致性) | ||
- 基于Nacos的动态配置 | ||
|
||
## 工具类 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
springmvc-service/src/main/java/com/doodl6/springmvc/service/config/NacosConfigService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.doodl6.springmvc.service.config; | ||
|
||
import com.alibaba.nacos.api.config.annotation.NacosValue; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* nacos配置服务 | ||
*/ | ||
@Service | ||
public class NacosConfigService { | ||
|
||
@NacosValue(value = "${maxPageSize:20}", autoRefreshed = true) | ||
private int maxPageSize; | ||
|
||
public int getMaxPageSize() { | ||
return maxPageSize; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
springmvc-web/src/main/java/com/doodl6/springmvc/web/controller/ConfigController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.doodl6.springmvc.web.controller; | ||
|
||
import com.doodl6.springmvc.service.config.NacosConfigService; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import javax.annotation.Resource; | ||
|
||
/** | ||
* 配置控制类 | ||
*/ | ||
@RestController | ||
@RequestMapping("/config") | ||
public class ConfigController extends BaseController { | ||
|
||
@Resource | ||
private NacosConfigService nacosConfigService; | ||
|
||
@GetMapping(value = "/getMaxPageSize") | ||
public int getMaxPageSize() { | ||
return nacosConfigService.getMaxPageSize(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:nacos="http://nacos.io/schema/nacos" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://nacos.io/schema/nacos http://nacos.io/schema/nacos.xsd | ||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> | ||
|
||
<!--nacos配置,这里是使用配置文件的方式,这只是其中的一种方式--> | ||
<!--开启注解--> | ||
<nacos:annotation-driven/> | ||
<!--指定nacos配置地址--> | ||
<nacos:global-properties server-addr="127.0.0.1:8848"/> | ||
<!--指定dataId,group-id, 是否是自动刷新--> | ||
<nacos:property-source data-id="doodl6" group-id="spring-mvc" auto-refreshed="true"/> | ||
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters