diff --git a/.gitignore b/.gitignore
index f024062f0..8af9b81d5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,3 +28,4 @@ hs_err_pid*
.idea/
*.iml
out/
+*/target/
diff --git a/nacos-spring-boot-example/nacos-spring-boot-config-example/pom.xml b/nacos-spring-boot-example/nacos-spring-boot-config-example/pom.xml
index 79395bb71..2a69e8af4 100644
--- a/nacos-spring-boot-example/nacos-spring-boot-config-example/pom.xml
+++ b/nacos-spring-boot-example/nacos-spring-boot-config-example/pom.xml
@@ -12,7 +12,7 @@
nacos-spring-boot-config-example
- 0.2.0-RC1
+ 0.2.1
@@ -21,10 +21,21 @@
spring-boot-starter-web
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
com.alibaba.boot
nacos-config-spring-boot-starter
${nacos-config-spring-boot.version}
+
+
+ com.alibaba.boot
+ nacos-config-spring-boot-actuator
+ ${nacos-config-spring-boot.version}
+
\ No newline at end of file
diff --git a/nacos-spring-boot-example/nacos-spring-boot-config-example/src/main/java/com/alibaba/nacos/example/spring/boot/NacosConfigApplication.java b/nacos-spring-boot-example/nacos-spring-boot-config-example/src/main/java/com/alibaba/nacos/example/spring/boot/NacosConfigApplication.java
index e94ebcb2e..73b501f9e 100644
--- a/nacos-spring-boot-example/nacos-spring-boot-config-example/src/main/java/com/alibaba/nacos/example/spring/boot/NacosConfigApplication.java
+++ b/nacos-spring-boot-example/nacos-spring-boot-config-example/src/main/java/com/alibaba/nacos/example/spring/boot/NacosConfigApplication.java
@@ -4,11 +4,22 @@
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
+/**
+ * Document: https://help.aliyun.com/document_detail/94592.html
+ *
+ * ACM 控制台添加配置:
+ *
+ * Data ID:com.alibaba.nacos.example.properties
+ *
+ * Group:DEFAULT_GROUP
+ *
+ * 配置内容:connectTimeoutInMills=5000
+ */
@SpringBootApplication
-@NacosPropertySource(dataId = "example", autoRefreshed = true)
+@NacosPropertySource(dataId = "com.alibaba.nacos.example.properties", autoRefreshed = true)
public class NacosConfigApplication {
public static void main(String[] args) {
SpringApplication.run(NacosConfigApplication.class, args);
}
-}
+}
\ No newline at end of file
diff --git a/nacos-spring-boot-example/nacos-spring-boot-config-example/src/main/java/com/alibaba/nacos/example/spring/boot/controller/ConfigController.java b/nacos-spring-boot-example/nacos-spring-boot-config-example/src/main/java/com/alibaba/nacos/example/spring/boot/controller/ConfigController.java
index f024c77fa..7edbc7909 100644
--- a/nacos-spring-boot-example/nacos-spring-boot-config-example/src/main/java/com/alibaba/nacos/example/spring/boot/controller/ConfigController.java
+++ b/nacos-spring-boot-example/nacos-spring-boot-config-example/src/main/java/com/alibaba/nacos/example/spring/boot/controller/ConfigController.java
@@ -1,6 +1,6 @@
package com.alibaba.nacos.example.spring.boot.controller;
-import org.springframework.beans.factory.annotation.Value;
+import com.alibaba.nacos.api.config.annotation.NacosValue;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@@ -11,16 +11,12 @@
@RequestMapping("config")
public class ConfigController {
- @Value("${useLocalCache:false}")
- private boolean useLocalCache;
-
- public void setUseLocalCache(boolean useLocalCache) {
- this.useLocalCache = useLocalCache;
- }
+ @NacosValue(value = "${connectTimeoutInMills:5000}", autoRefreshed = true)
+ private int connectTimeoutInMills;
@RequestMapping(value = "/get", method = GET)
@ResponseBody
- public boolean get() {
- return useLocalCache;
+ public int get() {
+ return connectTimeoutInMills;
}
}
\ No newline at end of file
diff --git a/nacos-spring-boot-example/nacos-spring-boot-config-example/src/main/resources/application.properties b/nacos-spring-boot-example/nacos-spring-boot-config-example/src/main/resources/application.properties
index 25dd747a8..3daa51fce 100644
--- a/nacos-spring-boot-example/nacos-spring-boot-config-example/src/main/resources/application.properties
+++ b/nacos-spring-boot-example/nacos-spring-boot-config-example/src/main/resources/application.properties
@@ -1 +1,12 @@
-nacos.config.server-addr=127.0.0.1:8848
\ No newline at end of file
+# \u5728\u547D\u540D\u7A7A\u95F4\u8BE6\u60C5\u5904\u53EF\u4EE5\u83B7\u53D6\u5230 endpoint \u548C namespace \u7684\u503C
+nacos.config.endpoint=xxx
+nacos.config.namespace=xxx
+
+# \u63A8\u8350\u4F7F\u7528 RAM \u8D26\u6237\u7684 accessKey \u548C secretKey
+nacos.config.access-key=xxx
+nacos.config.secret-key=xxx
+
+# endpoint http://localhost:8080/actuator/nacos-config
+# health http://localhost:8080/actuator/health
+management.endpoints.web.exposure.include=*
+management.endpoint.health.show-details=always
\ No newline at end of file
diff --git a/nacos-spring-boot-example/nacos-spring-boot-discovery-example/pom.xml b/nacos-spring-boot-example/nacos-spring-boot-discovery-example/pom.xml
index 60093ffe1..b0062e445 100644
--- a/nacos-spring-boot-example/nacos-spring-boot-discovery-example/pom.xml
+++ b/nacos-spring-boot-example/nacos-spring-boot-discovery-example/pom.xml
@@ -12,7 +12,7 @@
nacos-spring-boot-discovery-example
- 0.2.0-RC1
+ 0.2.1
diff --git a/nacos-spring-boot-example/nacos-spring-boot-discovery-example/src/main/resources/application.properties b/nacos-spring-boot-example/nacos-spring-boot-discovery-example/src/main/resources/application.properties
deleted file mode 100644
index db6453626..000000000
--- a/nacos-spring-boot-example/nacos-spring-boot-discovery-example/src/main/resources/application.properties
+++ /dev/null
@@ -1 +0,0 @@
-nacos.discovery.server-addr=127.0.0.1:8848
\ No newline at end of file
diff --git a/nacos-spring-boot-example/pom.xml b/nacos-spring-boot-example/pom.xml
index 9ede32bfd..3a3332e7a 100644
--- a/nacos-spring-boot-example/pom.xml
+++ b/nacos-spring-boot-example/pom.xml
@@ -26,10 +26,13 @@
+
org.springframework.boot
- spring-boot-starter-web
+ spring-boot-dependencies
${spring-boot.version}
+ pom
+ import
diff --git a/nacos-spring-cloud-example/nacos-spring-cloud-config-example/pom.xml b/nacos-spring-cloud-example/nacos-spring-cloud-config-example/pom.xml
index a413b81fb..612622d05 100644
--- a/nacos-spring-cloud-example/nacos-spring-cloud-config-example/pom.xml
+++ b/nacos-spring-cloud-example/nacos-spring-cloud-config-example/pom.xml
@@ -17,11 +17,11 @@
org.springframework.boot
spring-boot-starter-web
-
+
org.springframework.cloud
spring-cloud-starter-alibaba-nacos-config
- 0.2.0.RELEASE
+ 0.2.1.RELEASE
diff --git a/nacos-spring-cloud-example/nacos-spring-cloud-config-example/src/main/java/com/alibaba/nacos/example/spring/cloud/NacosConfigApplication.java b/nacos-spring-cloud-example/nacos-spring-cloud-config-example/src/main/java/com/alibaba/nacos/example/spring/cloud/NacosConfigApplication.java
index d4c2570b9..74105dca6 100644
--- a/nacos-spring-cloud-example/nacos-spring-cloud-config-example/src/main/java/com/alibaba/nacos/example/spring/cloud/NacosConfigApplication.java
+++ b/nacos-spring-cloud-example/nacos-spring-cloud-config-example/src/main/java/com/alibaba/nacos/example/spring/cloud/NacosConfigApplication.java
@@ -4,7 +4,7 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
- * @author xiaojing
+ * Document: https://help.aliyun.com/document_detail/94708.html
*/
@SpringBootApplication
public class NacosConfigApplication {
diff --git a/nacos-spring-cloud-example/nacos-spring-cloud-config-example/src/main/java/com/alibaba/nacos/example/spring/cloud/controller/ConfigController.java b/nacos-spring-cloud-example/nacos-spring-cloud-config-example/src/main/java/com/alibaba/nacos/example/spring/cloud/controller/ConfigController.java
index 8a06680aa..751ce2a3e 100644
--- a/nacos-spring-cloud-example/nacos-spring-cloud-config-example/src/main/java/com/alibaba/nacos/example/spring/cloud/controller/ConfigController.java
+++ b/nacos-spring-cloud-example/nacos-spring-cloud-config-example/src/main/java/com/alibaba/nacos/example/spring/cloud/controller/ConfigController.java
@@ -3,18 +3,25 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
+import static org.springframework.web.bind.annotation.RequestMethod.GET;
+
@RestController
@RequestMapping("/config")
@RefreshScope
public class ConfigController {
- @Value("${useLocalCache:false}")
- private boolean useLocalCache;
+ @Value("${connectTimeoutInMills:5000}")
+ private int connectTimeoutInMills;
- @RequestMapping("/get")
- public boolean get() {
- return useLocalCache;
+ /**
+ * http://localhost:8080/config/get
+ */
+ @RequestMapping(value = "/get", method = GET)
+ @ResponseBody
+ public int get() {
+ return connectTimeoutInMills;
}
}
\ No newline at end of file
diff --git a/nacos-spring-cloud-example/nacos-spring-cloud-config-example/src/main/resources/bootstrap.properties b/nacos-spring-cloud-example/nacos-spring-cloud-config-example/src/main/resources/bootstrap.properties
index 10ade11e6..925de2781 100644
--- a/nacos-spring-cloud-example/nacos-spring-cloud-config-example/src/main/resources/bootstrap.properties
+++ b/nacos-spring-cloud-example/nacos-spring-cloud-config-example/src/main/resources/bootstrap.properties
@@ -1,3 +1,16 @@
-spring.cloud.nacos.config.server-addr=127.0.0.1:8848
+# \u5728\u547D\u540D\u7A7A\u95F4\u8BE6\u60C5\u5904\u53EF\u4EE5\u83B7\u53D6\u5230 endpoint \u548C namespace \u7684\u503C
+spring.cloud.nacos.config.endpoint=xxx
+spring.cloud.nacos.config.namespace=xxx
-spring.application.name=example
\ No newline at end of file
+# \u63A8\u8350\u4F7F\u7528 RAM \u8D26\u6237\u7684 accessKey \u548C secretKey
+spring.cloud.nacos.config.access-key=xxx
+spring.cloud.nacos.config.secret-key=xxx
+
+# ACM \u63A7\u5236\u53F0\u6DFB\u52A0\u914D\u7F6E\uFF1A
+# Data ID\uFF1Acom.alibaba.nacos.example.properties
+# Group\uFF1ADEFAULT_GROUP
+# \u914D\u7F6E\u5185\u5BB9\uFF1AconnectTimeoutInMills=5000
+spring.application.name=com.alibaba.nacos.example
+# \u6307\u5B9A\u914D\u7F6E\u7684\u540E\u7F00\uFF0C\u652F\u6301 properties\u3001yaml\u3001yml\uFF0C\u9ED8\u8BA4\u4E3A properties
+spring.cloud.nacos.config.file-extension=properties
+#spring.cloud.nacos.config.file-extension=yaml
\ No newline at end of file
diff --git a/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/pom.xml b/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/pom.xml
new file mode 100644
index 000000000..0090628b3
--- /dev/null
+++ b/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/pom.xml
@@ -0,0 +1,44 @@
+
+
+
+ nacos-spring-cloud-example
+ com.alibaba.nacos
+ 0.2.0-SNAPSHOT
+
+ 4.0.0
+
+ nacos-spring-cloud-config-multi-data-ids-example
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-alibaba-nacos-config
+ 0.2.1.RELEASE
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-jpa
+
+
+
+ mysql
+ mysql-connector-java
+ 5.1.47
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+
+
\ No newline at end of file
diff --git a/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/cloud/UserApplication.java b/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/cloud/UserApplication.java
new file mode 100644
index 000000000..2eab5a6e8
--- /dev/null
+++ b/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/cloud/UserApplication.java
@@ -0,0 +1,30 @@
+package com.alibaba.nacos.example.spring.cloud;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.Bean;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+/**
+ * @author xiaojing
+ */
+@SpringBootApplication
+public class UserApplication {
+
+ @Bean
+ public RedisTemplate redisTemplate(RedisConnectionFactory factory) {
+ RedisTemplate redisTemplate = new RedisTemplate<>();
+ redisTemplate.setConnectionFactory(factory);
+ redisTemplate.setKeySerializer(new StringRedisSerializer());
+ redisTemplate.setHashKeySerializer(new StringRedisSerializer());
+ return redisTemplate;
+ }
+
+ public static void main(String[] args) {
+ SpringApplication.run(UserApplication.class, args);
+ }
+}
+
+
diff --git a/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/cloud/controller/UserController.java b/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/cloud/controller/UserController.java
new file mode 100644
index 000000000..22783f7be
--- /dev/null
+++ b/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/cloud/controller/UserController.java
@@ -0,0 +1,30 @@
+package com.alibaba.nacos.example.spring.cloud.controller;
+
+import com.alibaba.nacos.example.spring.cloud.model.User;
+import com.alibaba.nacos.example.spring.cloud.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("user")
+public class UserController {
+
+ private final UserService userService;
+
+ @Autowired
+ public UserController(UserService userService) {this.userService = userService;}
+
+ /**
+ * http://localhost:8080/user?id=1
+ */
+ @GetMapping
+ @ResponseBody
+ public User get(@RequestParam long id) {
+ return userService.findById(id);
+ }
+
+}
\ No newline at end of file
diff --git a/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/cloud/dao/UserRepository.java b/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/cloud/dao/UserRepository.java
new file mode 100644
index 000000000..2f8b45a03
--- /dev/null
+++ b/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/cloud/dao/UserRepository.java
@@ -0,0 +1,8 @@
+package com.alibaba.nacos.example.spring.cloud.dao;
+
+import com.alibaba.nacos.example.spring.cloud.model.User;
+import org.springframework.data.repository.CrudRepository;
+
+public interface UserRepository extends CrudRepository {
+
+}
\ No newline at end of file
diff --git a/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/cloud/model/User.java b/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/cloud/model/User.java
new file mode 100644
index 000000000..15a573d95
--- /dev/null
+++ b/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/cloud/model/User.java
@@ -0,0 +1,39 @@
+package com.alibaba.nacos.example.spring.cloud.model;
+
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import java.io.Serializable;
+
+/**
+ * CREATE TABLE `user` (
+ * `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ * `name` varchar(10) NOT NULL DEFAULT '',
+ * PRIMARY KEY (`id`)
+ * ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+ */
+@Entity
+public class User implements Serializable {
+ @Id
+ @GeneratedValue(strategy = GenerationType.AUTO)
+ private Long id;
+
+ private String name;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/cloud/service/UserService.java b/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/cloud/service/UserService.java
new file mode 100644
index 000000000..a076829e0
--- /dev/null
+++ b/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/cloud/service/UserService.java
@@ -0,0 +1,16 @@
+package com.alibaba.nacos.example.spring.cloud.service;
+
+import com.alibaba.nacos.example.spring.cloud.model.User;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author hexu.hxy
+ * @date 2019/1/7
+ */
+
+@Service
+public interface UserService {
+
+ User findById(Long id);
+
+}
\ No newline at end of file
diff --git a/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/cloud/service/impl/UserServiceImpl.java b/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/cloud/service/impl/UserServiceImpl.java
new file mode 100644
index 000000000..0584fa7a8
--- /dev/null
+++ b/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/cloud/service/impl/UserServiceImpl.java
@@ -0,0 +1,65 @@
+package com.alibaba.nacos.example.spring.cloud.service.impl;
+
+import com.alibaba.nacos.example.spring.cloud.dao.UserRepository;
+import com.alibaba.nacos.example.spring.cloud.model.User;
+import com.alibaba.nacos.example.spring.cloud.service.UserService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+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.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author hexu.hxy
+ * @date 2019/1/7
+ */
+
+@Service
+@RefreshScope
+public class UserServiceImpl implements UserService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(UserServiceImpl.class);
+
+ private final UserRepository userRepository;
+
+ private final RedisTemplate redisTemplate;
+
+ @Value("${app.user.cache}")
+ private boolean cache;
+
+ @Autowired
+ public UserServiceImpl(UserRepository userRepository, RedisTemplate redisTemplate) {
+ this.userRepository = userRepository;
+ this.redisTemplate = redisTemplate;
+ }
+
+ @Override
+ public User findById(Long id) {
+ LOGGER.info("cache: {}", cache);
+
+ if (cache) {
+ Object obj = redisTemplate.opsForValue().get(key(id));
+ if (obj != null) {
+ LOGGER.info("get user from cache, id: {}", id);
+ return (User)obj;
+ }
+ }
+
+ User user = userRepository.findById(id).orElse(null);
+ if (user != null) {
+ if (cache) {
+ LOGGER.info("set cache for user, id: {}", id);
+ redisTemplate.opsForValue().set(key(id), user);
+ }
+ }
+
+ return user;
+ }
+
+ private String key(Long id) {
+ return String.format("nacos-spring-cloud-config-multi-data-ids-example:user:%d", id);
+ }
+
+}
\ No newline at end of file
diff --git a/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/resources/bootstrap.properties b/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/resources/bootstrap.properties
new file mode 100644
index 000000000..d28e7d6b9
--- /dev/null
+++ b/nacos-spring-cloud-example/nacos-spring-cloud-config-multi-data-ids-example/src/main/resources/bootstrap.properties
@@ -0,0 +1,45 @@
+spring.application.name=multi-data-ids-example
+
+# \u5728\u547D\u540D\u7A7A\u95F4\u8BE6\u60C5\u5904\u53EF\u4EE5\u83B7\u53D6\u5230 endpoint \u548C namespace \u7684\u503C
+spring.cloud.nacos.config.endpoint=xxx
+spring.cloud.nacos.config.namespace=xxx
+
+# \u63A8\u8350\u4F7F\u7528 RAM \u8D26\u6237\u7684 accessKey \u548C secretKey
+spring.cloud.nacos.config.access-key=xxx
+spring.cloud.nacos.config.secret-key=xxx
+
+# 0.2.1.RELEASE \u4EE5\u4E0A\u652F\u6301\u591A\u4E2A\u914D\u7F6E\uFF0C\u6587\u6863\uFF1Ahttps://github.com/spring-cloud-incubator/spring-cloud-alibaba/wiki/Nacos-config
+
+# ACM \u63A7\u5236\u53F0\u6DFB\u52A0\u914D\u7F6E\uFF1A
+# Data ID\uFF1Aapp.properties
+# Group\uFF1Amulti-data-ids
+# \u914D\u7F6E\u5185\u5BB9\uFF1Aapp.user.cache=false
+spring.cloud.nacos.config.ext-config[0].data-id=app.properties
+spring.cloud.nacos.config.ext-config[0].group=multi-data-ids
+spring.cloud.nacos.config.ext-config[0].refresh=true
+
+# ACM \u63A7\u5236\u53F0\u6DFB\u52A0\u914D\u7F6E\uFF1A
+# Data ID\uFF1Adatasource.properties
+# Group\uFF1Amulti-data-ids
+# \u914D\u7F6E\u5185\u5BB9\u793A\u4F8B\uFF1A
+# spring.datasource.url=jdbc:mysql://localhost:3306/test?useSSL=false
+# spring.datasource.username=root
+# spring.datasource.password=root
+# spring.datasource.initial-size=10
+# spring.datasource.max-active=20
+spring.cloud.nacos.config.ext-config[1].data-id=datasource.properties
+spring.cloud.nacos.config.ext-config[1].group=multi-data-ids
+
+# ACM \u63A7\u5236\u53F0\u6DFB\u52A0\u914D\u7F6E\uFF1A
+# Data ID\uFF1Aredis.properties
+# Group\uFF1Amulti-data-ids
+# \u914D\u7F6E\u5185\u5BB9\u793A\u4F8B\uFF1A
+# spring.redis.host=localhost
+# spring.redis.password=20190101
+# spring.redis.timeout=5000
+# spring.redis.max-idle=5
+# spring.redis.max-active=10
+# spring.redis.max-wait=3000
+# spring.redis.test-on-borrow=false
+spring.cloud.nacos.config.ext-config[2].data-id=redis.properties
+spring.cloud.nacos.config.ext-config[2].group=multi-data-ids
\ No newline at end of file
diff --git a/nacos-spring-cloud-example/pom.xml b/nacos-spring-cloud-example/pom.xml
index 686328031..52200ed01 100644
--- a/nacos-spring-cloud-example/pom.xml
+++ b/nacos-spring-cloud-example/pom.xml
@@ -12,6 +12,9 @@
2.0.4.RELEASE
Finchley.RELEASE
+
+ 1.8
+ 1.8
4.0.0
@@ -21,6 +24,7 @@
pom
nacos-spring-cloud-config-example
+ nacos-spring-cloud-config-multi-data-ids-example
nacos-spring-cloud-discovery-example
diff --git a/nacos-spring-example/nacos-spring-config-datasource-example/pom.xml b/nacos-spring-example/nacos-spring-config-datasource-example/pom.xml
new file mode 100644
index 000000000..adee0b59e
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-datasource-example/pom.xml
@@ -0,0 +1,74 @@
+
+
+
+
+ nacos-spring-example
+ com.alibaba.nacos
+ 0.2.0-SNAPSHOT
+
+
+ 4.0.0
+
+ nacos-spring-config-datasource-example
+ pom
+
+ nacos-spring-config-datasource-example
+
+ http://nacos.io
+
+
+
+
+ javax.servlet
+ javax.servlet-api
+
+
+
+ org.springframework
+ spring-webmvc
+
+
+
+ org.springframework
+ spring-jdbc
+ 3.2.18.RELEASE
+
+
+
+ org.springframework
+ spring-tx
+ 3.2.18.RELEASE
+
+
+
+ com.alibaba.nacos
+ nacos-spring-context
+
+
+
+ mysql
+ mysql-connector-java
+ 5.1.40
+
+
+
+ com.alibaba
+ druid
+ 1.1.12
+
+
+
+ org.mybatis
+ mybatis
+ 3.4.6
+
+
+
+ org.mybatis
+ mybatis-spring
+ 1.3.2
+
+
+
+
diff --git a/nacos-spring-example/nacos-spring-config-datasource-example/src/main/java/com/alibaba/nacos/example/spring/controller/UserController.java b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/java/com/alibaba/nacos/example/spring/controller/UserController.java
new file mode 100644
index 000000000..e03d59cc2
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/java/com/alibaba/nacos/example/spring/controller/UserController.java
@@ -0,0 +1,25 @@
+package com.alibaba.nacos.example.spring.controller;
+
+import com.alibaba.nacos.example.spring.model.User;
+import com.alibaba.nacos.example.spring.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+@Controller("user")
+public class UserController {
+
+ private final UserService userService;
+
+ @Autowired
+ public UserController(UserService userService) {this.userService = userService;}
+
+ @RequestMapping
+ @ResponseBody
+ public User get(@RequestParam int id) {
+ return userService.findById(id);
+ }
+
+}
\ No newline at end of file
diff --git a/nacos-spring-example/nacos-spring-config-datasource-example/src/main/java/com/alibaba/nacos/example/spring/dao/UserMapper.java b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/java/com/alibaba/nacos/example/spring/dao/UserMapper.java
new file mode 100644
index 000000000..8a210712b
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/java/com/alibaba/nacos/example/spring/dao/UserMapper.java
@@ -0,0 +1,11 @@
+package com.alibaba.nacos.example.spring.dao;
+
+import com.alibaba.nacos.example.spring.model.User;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+
+public interface UserMapper {
+
+ @Select(value = "select id, name from user where id = #{id}")
+ User findById(@Param("id") long id);
+}
\ No newline at end of file
diff --git a/nacos-spring-example/nacos-spring-config-datasource-example/src/main/java/com/alibaba/nacos/example/spring/model/User.java b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/java/com/alibaba/nacos/example/spring/model/User.java
new file mode 100644
index 000000000..3b2f4da24
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/java/com/alibaba/nacos/example/spring/model/User.java
@@ -0,0 +1,24 @@
+package com.alibaba.nacos.example.spring.model;
+
+public class User {
+
+ private Integer id;
+
+ private String name;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/nacos-spring-example/nacos-spring-config-datasource-example/src/main/java/com/alibaba/nacos/example/spring/service/UserService.java b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/java/com/alibaba/nacos/example/spring/service/UserService.java
new file mode 100644
index 000000000..663828a6c
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/java/com/alibaba/nacos/example/spring/service/UserService.java
@@ -0,0 +1,10 @@
+package com.alibaba.nacos.example.spring.service;
+
+import com.alibaba.nacos.example.spring.model.User;
+import org.springframework.stereotype.Service;
+
+@Service
+public interface UserService {
+
+ User findById(Integer id);
+}
\ No newline at end of file
diff --git a/nacos-spring-example/nacos-spring-config-datasource-example/src/main/java/com/alibaba/nacos/example/spring/service/impl/UserServiceImpl.java b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/java/com/alibaba/nacos/example/spring/service/impl/UserServiceImpl.java
new file mode 100644
index 000000000..65eefe0fc
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/java/com/alibaba/nacos/example/spring/service/impl/UserServiceImpl.java
@@ -0,0 +1,21 @@
+package com.alibaba.nacos.example.spring.service.impl;
+
+import com.alibaba.nacos.example.spring.dao.UserMapper;
+import com.alibaba.nacos.example.spring.model.User;
+import com.alibaba.nacos.example.spring.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class UserServiceImpl implements UserService {
+
+ private final UserMapper userMapper;
+
+ @Autowired
+ public UserServiceImpl(UserMapper userMapper) {this.userMapper = userMapper;}
+
+ @Override
+ public User findById(Integer id) {
+ return userMapper.findById(id);
+ }
+}
\ No newline at end of file
diff --git a/nacos-spring-example/nacos-spring-config-datasource-example/src/main/resources/user.sql b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/resources/user.sql
new file mode 100644
index 000000000..f0691cc39
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/resources/user.sql
@@ -0,0 +1,9 @@
+CREATE TABLE `user` (
+ `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ `name` varchar(10) NOT NULL DEFAULT '' COMMENT '名字',
+ `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+ `update_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+ PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='用户表';
+
+INSERT INTO `user` (`name`, `create_time`, `update_time`) VALUES ('Nacos', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP);
\ No newline at end of file
diff --git a/nacos-spring-example/nacos-spring-config-datasource-example/src/main/webapp/WEB-INF/datasource.xml b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/webapp/WEB-INF/datasource.xml
new file mode 100644
index 000000000..c13040378
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/webapp/WEB-INF/datasource.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nacos-spring-example/nacos-spring-config-datasource-example/src/main/webapp/WEB-INF/dispatcher-servlet.xml b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/webapp/WEB-INF/dispatcher-servlet.xml
new file mode 100644
index 000000000..5f1d51e0d
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/webapp/WEB-INF/dispatcher-servlet.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nacos-spring-example/nacos-spring-config-datasource-example/src/main/webapp/WEB-INF/nacos.xml b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/webapp/WEB-INF/nacos.xml
new file mode 100644
index 000000000..0f6739dd6
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/webapp/WEB-INF/nacos.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nacos-spring-example/nacos-spring-config-datasource-example/src/main/webapp/WEB-INF/spring-config-mybatis.xml b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/webapp/WEB-INF/spring-config-mybatis.xml
new file mode 100644
index 000000000..22374a35c
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/webapp/WEB-INF/spring-config-mybatis.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nacos-spring-example/nacos-spring-config-datasource-example/src/main/webapp/WEB-INF/web.xml b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 000000000..5833e24f6
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,17 @@
+
+
+
+
+ dispatcher
+ org.springframework.web.servlet.DispatcherServlet
+ 1
+
+
+
+ dispatcher
+ /
+
+
+
\ No newline at end of file
diff --git a/nacos-spring-example/nacos-spring-config-datasource-example/src/main/webapp/index.jsp b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/webapp/index.jsp
new file mode 100644
index 000000000..c38169bb9
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-datasource-example/src/main/webapp/index.jsp
@@ -0,0 +1,5 @@
+
+
+Hello World!
+
+
diff --git a/nacos-spring-example/nacos-spring-config-example/src/main/java/com/alibaba/nacos/example/spring/NacosConfiguration.java b/nacos-spring-example/nacos-spring-config-example/src/main/java/com/alibaba/nacos/example/spring/NacosConfiguration.java
index 9be6c1e28..12c5918a3 100644
--- a/nacos-spring-example/nacos-spring-config-example/src/main/java/com/alibaba/nacos/example/spring/NacosConfiguration.java
+++ b/nacos-spring-example/nacos-spring-config-example/src/main/java/com/alibaba/nacos/example/spring/NacosConfiguration.java
@@ -6,8 +6,26 @@
import org.springframework.context.annotation.Configuration;
@Configuration
-@EnableNacosConfig(globalProperties = @NacosProperties(serverAddr = "127.0.0.1:8848"))
-@NacosPropertySource(dataId = "example", autoRefreshed = true)
+// 在命名空间详情处可以获取到 endpoint 和 namespace;accessKey 和 secretKey 推荐使用 RAM 账户的
+@EnableNacosConfig(globalProperties = @NacosProperties(
+ endpoint = "xxx",
+ namespace = "xxx",
+ accessKey = "xxx",
+ secretKey = "xxx"
+))
+
+/**
+ * Document: https://help.aliyun.com/document_detail/94588.html
+ *
+ * ACM 控制台添加配置:
+ *
+ * Data ID:com.alibaba.nacos.example
+ *
+ * Group:DEFAULT_GROUP
+ *
+ * 配置内容:connectTimeoutInMills=5000
+ */
+@NacosPropertySource(dataId = "com.alibaba.nacos.example", autoRefreshed = true)
public class NacosConfiguration {
}
\ No newline at end of file
diff --git a/nacos-spring-example/nacos-spring-config-example/src/main/java/com/alibaba/nacos/example/spring/controller/ConfigController.java b/nacos-spring-example/nacos-spring-config-example/src/main/java/com/alibaba/nacos/example/spring/controller/ConfigController.java
index 7103f3a3b..21e78227c 100644
--- a/nacos-spring-example/nacos-spring-config-example/src/main/java/com/alibaba/nacos/example/spring/controller/ConfigController.java
+++ b/nacos-spring-example/nacos-spring-config-example/src/main/java/com/alibaba/nacos/example/spring/controller/ConfigController.java
@@ -1,27 +1,48 @@
package com.alibaba.nacos.example.spring.controller;
-import org.springframework.beans.factory.annotation.Value;
+import com.alibaba.nacos.api.annotation.NacosInjected;
+import com.alibaba.nacos.api.config.ConfigService;
+import com.alibaba.nacos.api.config.annotation.NacosValue;
+import com.alibaba.nacos.api.exception.NacosException;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import static org.springframework.web.bind.annotation.RequestMethod.GET;
+import static org.springframework.web.bind.annotation.RequestMethod.POST;
@Controller
@RequestMapping("config")
public class ConfigController {
- @Value("${useLocalCache:false}")
- private boolean useLocalCache;
+ @NacosInjected
+ private ConfigService configService;
- public void setUseLocalCache(boolean useLocalCache) {
- this.useLocalCache = useLocalCache;
- }
+ @NacosValue(value = "${connectTimeoutInMills:5000}", autoRefreshed = true)
+ private int connectTimeoutInMills;
@RequestMapping(value = "/get", method = GET)
@ResponseBody
- public boolean get() {
- return useLocalCache;
+ public int get() {
+ return connectTimeoutInMills;
+ }
+
+ /**
+ * curl -X POST 'http://localhost:8080/config?dataId=com.alibaba.nacos.example&content=connectTimeoutInMills=3000'
+ */
+ @RequestMapping(method = POST)
+ @ResponseBody
+ public ResponseEntity publish(@RequestParam String dataId,
+ @RequestParam(defaultValue = "DEFAULT_GROUP") String group,
+ @RequestParam String content) throws NacosException {
+ boolean result = configService.publishConfig(dataId, group, content);
+ if (result) {
+ return new ResponseEntity("Success", HttpStatus.OK);
+ }
+ return new ResponseEntity("Fail", HttpStatus.INTERNAL_SERVER_ERROR);
}
}
diff --git a/nacos-spring-example/nacos-spring-config-listener-example/pom.xml b/nacos-spring-example/nacos-spring-config-listener-example/pom.xml
new file mode 100644
index 000000000..34d4b635f
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-listener-example/pom.xml
@@ -0,0 +1,37 @@
+
+
+
+
+ nacos-spring-example
+ com.alibaba.nacos
+ 0.2.0-SNAPSHOT
+
+
+ 4.0.0
+
+ nacos-spring-config-listener-example
+ pom
+
+ nacos-spring-config-listener-example
+
+ http://nacos.io
+
+
+
+
+ javax.servlet
+ javax.servlet-api
+
+
+
+ org.springframework
+ spring-webmvc
+
+
+
+ com.alibaba.nacos
+ nacos-spring-context
+
+
+
diff --git a/nacos-spring-example/nacos-spring-config-listener-example/src/main/java/com/alibaba/nacos/example/spring/AdminConfiguration.java b/nacos-spring-example/nacos-spring-config-listener-example/src/main/java/com/alibaba/nacos/example/spring/AdminConfiguration.java
new file mode 100644
index 000000000..4fdfffa39
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-listener-example/src/main/java/com/alibaba/nacos/example/spring/AdminConfiguration.java
@@ -0,0 +1,17 @@
+package com.alibaba.nacos.example.spring;
+
+import com.alibaba.nacos.api.annotation.NacosProperties;
+import com.alibaba.nacos.spring.context.annotation.config.EnableNacosConfig;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+// 在命名空间详情处可以获取到 endpoint 和 namespace;accessKey 和 secretKey 推荐使用 RAM 账户的
+@EnableNacosConfig(globalProperties = @NacosProperties(
+ endpoint = "xxx",
+ namespace = "xxx",
+ accessKey = "xxx",
+ secretKey = "xxx"
+))
+public class AdminConfiguration {
+
+}
\ No newline at end of file
diff --git a/nacos-spring-example/nacos-spring-config-listener-example/src/main/java/com/alibaba/nacos/example/spring/controller/AdminController.java b/nacos-spring-example/nacos-spring-config-listener-example/src/main/java/com/alibaba/nacos/example/spring/controller/AdminController.java
new file mode 100644
index 000000000..f5eeab613
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-listener-example/src/main/java/com/alibaba/nacos/example/spring/controller/AdminController.java
@@ -0,0 +1,29 @@
+package com.alibaba.nacos.example.spring.controller;
+
+import com.alibaba.nacos.example.spring.model.Admin;
+import com.alibaba.nacos.example.spring.service.AdminService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import static org.springframework.web.bind.annotation.RequestMethod.GET;
+
+/**
+ * @author hexu.hxy
+ */
+@Controller
+@RequestMapping("admin")
+public class AdminController {
+
+ @Autowired
+ private AdminService adminService;
+
+ @RequestMapping(method = GET, produces = MediaType.APPLICATION_JSON_VALUE)
+ @ResponseBody
+ public Admin get() {
+ return adminService.getAdmin();
+ }
+}
+
diff --git a/nacos-spring-example/nacos-spring-config-listener-example/src/main/java/com/alibaba/nacos/example/spring/converter/AdminConverter.java b/nacos-spring-example/nacos-spring-config-listener-example/src/main/java/com/alibaba/nacos/example/spring/converter/AdminConverter.java
new file mode 100644
index 000000000..93b19a2a2
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-listener-example/src/main/java/com/alibaba/nacos/example/spring/converter/AdminConverter.java
@@ -0,0 +1,24 @@
+package com.alibaba.nacos.example.spring.converter;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.nacos.api.config.convert.NacosConfigConverter;
+import com.alibaba.nacos.example.spring.model.Admin;
+
+/**
+ * @author hexu.hxy
+ */
+public class AdminConverter implements NacosConfigConverter {
+
+ @Override
+ public boolean canConvert(Class targetType) {
+ return Admin.class.equals(targetType);
+ }
+
+ /**
+ * 可自定义转化格式
+ */
+ @Override
+ public Admin convert(String config) {
+ return JSON.parseObject(config, Admin.class);
+ }
+}
\ No newline at end of file
diff --git a/nacos-spring-example/nacos-spring-config-listener-example/src/main/java/com/alibaba/nacos/example/spring/model/Admin.java b/nacos-spring-example/nacos-spring-config-listener-example/src/main/java/com/alibaba/nacos/example/spring/model/Admin.java
new file mode 100644
index 000000000..febc3a164
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-listener-example/src/main/java/com/alibaba/nacos/example/spring/model/Admin.java
@@ -0,0 +1,30 @@
+package com.alibaba.nacos.example.spring.model;
+
+public class Admin {
+ private String username;
+ private String password;
+
+ public String getUsername() {
+ return username;
+ }
+
+ public void setUsername(String username) {
+ this.username = username;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ @Override
+ public String toString() {
+ return "Admin{" +
+ "username='" + username + '\'' +
+ ", password='" + password + '\'' +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/nacos-spring-example/nacos-spring-config-listener-example/src/main/java/com/alibaba/nacos/example/spring/service/AdminService.java b/nacos-spring-example/nacos-spring-config-listener-example/src/main/java/com/alibaba/nacos/example/spring/service/AdminService.java
new file mode 100644
index 000000000..10ee5d65c
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-listener-example/src/main/java/com/alibaba/nacos/example/spring/service/AdminService.java
@@ -0,0 +1,12 @@
+package com.alibaba.nacos.example.spring.service;
+
+import com.alibaba.nacos.example.spring.model.Admin;
+
+/**
+ * @author hexu.hxy
+ * @date 2019/1/6
+ */
+public interface AdminService {
+
+ Admin getAdmin();
+}
diff --git a/nacos-spring-example/nacos-spring-config-listener-example/src/main/java/com/alibaba/nacos/example/spring/service/impl/AdminServiceImpl.java b/nacos-spring-example/nacos-spring-config-listener-example/src/main/java/com/alibaba/nacos/example/spring/service/impl/AdminServiceImpl.java
new file mode 100644
index 000000000..6c1225b66
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-listener-example/src/main/java/com/alibaba/nacos/example/spring/service/impl/AdminServiceImpl.java
@@ -0,0 +1,56 @@
+package com.alibaba.nacos.example.spring.service.impl;
+
+import com.alibaba.nacos.api.config.annotation.NacosConfigListener;
+import com.alibaba.nacos.example.spring.converter.AdminConverter;
+import com.alibaba.nacos.example.spring.model.Admin;
+import com.alibaba.nacos.example.spring.service.AdminService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+/**
+ * @author hexu.hxy
+ * @date 2019/1/6
+ */
+@Service
+public class AdminServiceImpl implements AdminService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(AdminServiceImpl.class);
+
+ private static final String ADMIN_DATA_ID = "admin.json";
+
+ private static final String ADMIN_GROUP_ID = "spring-listener";
+
+ private volatile Admin admin;
+
+
+ @NacosConfigListener(dataId = ADMIN_DATA_ID, groupId = ADMIN_GROUP_ID)
+ public void onReceived(String content) {
+ LOGGER.info("onReceived(String) : {}", content);
+ }
+
+ /**
+ *
+ * ACM 控制台添加配置:
+ *
+ * Data ID:admin.json
+ *
+ * Group:spring-listener
+ *
+ * 配置内容:
+ * {
+ * "username": "admin",
+ * "password": "123456"
+ * }
+ */
+ @NacosConfigListener(dataId = ADMIN_DATA_ID, groupId = ADMIN_GROUP_ID, converter = AdminConverter.class)
+ public void onReceived(Admin admin) {
+ LOGGER.info("onReceived(Admin) : {}", admin);
+ this.admin = admin;
+ }
+
+ @Override
+ public Admin getAdmin() {
+ return admin;
+ }
+}
diff --git a/nacos-spring-example/nacos-spring-config-listener-example/src/main/webapp/WEB-INF/dispatcherServlet-servlet.xml b/nacos-spring-example/nacos-spring-config-listener-example/src/main/webapp/WEB-INF/dispatcherServlet-servlet.xml
new file mode 100644
index 000000000..3ec4f2fc6
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-listener-example/src/main/webapp/WEB-INF/dispatcherServlet-servlet.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nacos-spring-example/nacos-spring-config-listener-example/src/main/webapp/WEB-INF/web.xml b/nacos-spring-example/nacos-spring-config-listener-example/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 000000000..2e1696d9b
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-listener-example/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,17 @@
+
+
+
+
+ dispatcherServlet
+ org.springframework.web.servlet.DispatcherServlet
+ 1
+
+
+
+ dispatcherServlet
+ /
+
+
+
\ No newline at end of file
diff --git a/nacos-spring-example/nacos-spring-config-listener-example/src/main/webapp/index.jsp b/nacos-spring-example/nacos-spring-config-listener-example/src/main/webapp/index.jsp
new file mode 100644
index 000000000..c38169bb9
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-listener-example/src/main/webapp/index.jsp
@@ -0,0 +1,5 @@
+
+
+Hello World!
+
+
diff --git a/nacos-spring-example/nacos-spring-config-multi-data-ids-example/pom.xml b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/pom.xml
new file mode 100644
index 000000000..72e89e406
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/pom.xml
@@ -0,0 +1,67 @@
+
+
+
+
+ nacos-spring-example
+ com.alibaba.nacos
+ 0.2.0-SNAPSHOT
+
+
+ 4.0.0
+
+ nacos-spring-config-multi-data-ids-example
+ pom
+
+ nacos-spring-config-multi-data-ids-example
+
+ http://nacos.io
+
+
+
+
+ javax.servlet
+ javax.servlet-api
+
+
+
+ org.springframework
+ spring-webmvc
+
+
+
+ org.springframework
+ spring-jdbc
+ 3.2.18.RELEASE
+
+
+
+ com.alibaba
+ druid
+ 1.1.12
+
+
+
+ mysql
+ mysql-connector-java
+ 5.1.40
+
+
+
+ org.springframework.data
+ spring-data-redis
+ 1.3.6.RELEASE
+
+
+
+ redis.clients
+ jedis
+ 2.4.1
+
+
+
+ com.alibaba.nacos
+ nacos-spring-context
+
+
+
diff --git a/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/NacosConfiguration.java b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/NacosConfiguration.java
new file mode 100644
index 000000000..9ebdbec3d
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/NacosConfiguration.java
@@ -0,0 +1,58 @@
+package com.alibaba.nacos.example.spring;
+
+import com.alibaba.nacos.api.annotation.NacosProperties;
+import com.alibaba.nacos.spring.context.annotation.config.EnableNacosConfig;
+import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
+import com.alibaba.nacos.spring.context.annotation.config.NacosPropertySources;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+
+// 在命名空间详情处可以获取到 endpoint 和 namespace;accessKey 和 secretKey 推荐使用 RAM 账户的
+@EnableNacosConfig(globalProperties = @NacosProperties(
+ endpoint = "xxx",
+ namespace = "xxx",
+ accessKey = "xxx",
+ secretKey = "xxx"
+))
+
+@NacosPropertySources({
+
+ /*
+ * ACM 控制台添加配置:
+ * Data ID:app.properties
+ * Group:multi-data-ids
+ * 配置内容:app.user.cache=false
+ */
+ @NacosPropertySource(dataId = "app.properties", groupId = "multi-data-ids", autoRefreshed = true),
+
+ /*
+ * ACM 控制台添加配置:
+ * Data ID:datasource.properties
+ * Group:multi-data-ids
+ * 配置内容示例:
+ * spring.datasource.url=jdbc:mysql://localhost:3306/test?useSSL=false
+ * spring.datasource.username=root
+ * spring.datasource.password=root
+ * spring.datasource.initial-size=10
+ * spring.datasource.max-active=20
+ */
+ @NacosPropertySource(dataId = "datasource.properties", groupId = "multi-data-ids"),
+
+ /* ACM 控制台添加配置:
+ * Data ID:redis.properties
+ * Group:multi-data-ids
+ * 配置内容示例:
+ * spring.redis.host=localhost
+ * spring.redis.password=20190101
+ * spring.redis.timeout=5000
+ * spring.redis.max-idle=5
+ * spring.redis.max-active=10
+ * spring.redis.max-wait=3000
+ * spring.redis.test-on-borrow=false
+ */
+ @NacosPropertySource(dataId = "redis.properties", groupId = "multi-data-ids")
+})
+public class NacosConfiguration {
+
+}
\ No newline at end of file
diff --git a/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/controller/UserController.java b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/controller/UserController.java
new file mode 100644
index 000000000..5afe953ab
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/controller/UserController.java
@@ -0,0 +1,33 @@
+package com.alibaba.nacos.example.spring.controller;
+
+import com.alibaba.nacos.example.spring.model.User;
+import com.alibaba.nacos.example.spring.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+/**
+ * @author hexu.hxy
+ */
+@Controller
+@RequestMapping("user")
+public class UserController {
+
+ private final UserService userService;
+
+ @Autowired
+ public UserController(UserService userService) {this.userService = userService;}
+
+ /**
+ * http://localhost:8080/user?id=1
+ */
+ @RequestMapping(method = RequestMethod.GET)
+ @ResponseBody
+ public User get(@RequestParam long id) {
+ return userService.findById(id);
+ }
+
+}
\ No newline at end of file
diff --git a/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/model/User.java b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/model/User.java
new file mode 100644
index 000000000..f5bdad544
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/model/User.java
@@ -0,0 +1,33 @@
+package com.alibaba.nacos.example.spring.model;
+
+import java.io.Serializable;
+
+/**
+ * CREATE TABLE `user` (
+ * `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
+ * `name` varchar(10) NOT NULL DEFAULT '',
+ * PRIMARY KEY (`id`)
+ * ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
+ */
+public class User implements Serializable {
+
+ private Long id;
+
+ private String name;
+
+ public Long getId() {
+ return id;
+ }
+
+ public void setId(Long id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
diff --git a/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/service/UserService.java b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/service/UserService.java
new file mode 100644
index 000000000..0639a9ece
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/service/UserService.java
@@ -0,0 +1,13 @@
+package com.alibaba.nacos.example.spring.service;
+
+import com.alibaba.nacos.example.spring.model.User;
+
+/**
+ * @author hexu.hxy
+ * @date 2019/1/7
+ */
+public interface UserService {
+
+ User findById(Long id);
+
+}
\ No newline at end of file
diff --git a/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/service/impl/UserServiceImpl.java b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/service/impl/UserServiceImpl.java
new file mode 100644
index 000000000..3a8ce59dd
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/java/com/alibaba/nacos/example/spring/service/impl/UserServiceImpl.java
@@ -0,0 +1,84 @@
+package com.alibaba.nacos.example.spring.service.impl;
+
+import com.alibaba.nacos.api.config.annotation.NacosValue;
+import com.alibaba.nacos.example.spring.model.User;
+import com.alibaba.nacos.example.spring.service.UserService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.EmptyResultDataAccessException;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.jdbc.core.RowMapper;
+import org.springframework.stereotype.Service;
+
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * @author hexu.hxy
+ * @date 2019/1/7
+ */
+@Service
+public class UserServiceImpl implements UserService {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(UserServiceImpl.class);
+
+ private final JdbcTemplate jdbcTemplate;
+
+ private final RedisTemplate redisTemplate;
+
+ @NacosValue(value = "${app.user.cache}", autoRefreshed = true)
+ private boolean cache;
+
+ @Autowired
+ public UserServiceImpl(JdbcTemplate jdbcTemplate, RedisTemplate redisTemplate) {
+ this.jdbcTemplate = jdbcTemplate;
+ this.redisTemplate = redisTemplate;
+ }
+
+ @Override
+ public User findById(Long id) {
+ LOGGER.info("cache: {}", cache);
+
+ if (cache) {
+ Object obj = redisTemplate.opsForValue().get(key(id));
+ if (obj != null) {
+ LOGGER.info("get user from cache, id: {}", id);
+ return (User)obj;
+ }
+ }
+
+ User user = getUser(id);
+ if (user != null) {
+ if (cache) {
+ LOGGER.info("set cache for user, id: {}", id);
+ redisTemplate.opsForValue().set(key(id), user);
+ }
+ }
+
+ return user;
+ }
+
+ private User getUser(Long id) {
+ try {
+ return jdbcTemplate.queryForObject("SELECT id, name FROM user WHERE id=?", new Object[] {id},
+ new RowMapper() {
+ @Override
+ public User mapRow(ResultSet rs, int rowNum) throws SQLException {
+ User user = new User();
+ user.setId(rs.getLong(1));
+ user.setName(rs.getString(2));
+ return user;
+ }
+ });
+ } catch (EmptyResultDataAccessException e) {
+ return null;
+ }
+ }
+
+ private String key(Long id) {
+ return String.format("nacos-spring-config-multi-data-ids-example:user:%d", id);
+ }
+
+}
\ No newline at end of file
diff --git a/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/webapp/WEB-INF/cache.xml b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/webapp/WEB-INF/cache.xml
new file mode 100644
index 000000000..8e5ca5d3a
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/webapp/WEB-INF/cache.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/webapp/WEB-INF/datasource.xml b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/webapp/WEB-INF/datasource.xml
new file mode 100644
index 000000000..1efe1a8d5
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/webapp/WEB-INF/datasource.xml
@@ -0,0 +1,28 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/webapp/WEB-INF/dispatcherServlet-servlet.xml b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/webapp/WEB-INF/dispatcherServlet-servlet.xml
new file mode 100644
index 000000000..ac868c276
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/webapp/WEB-INF/dispatcherServlet-servlet.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/webapp/WEB-INF/web.xml b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 000000000..2e1696d9b
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,17 @@
+
+
+
+
+ dispatcherServlet
+ org.springframework.web.servlet.DispatcherServlet
+ 1
+
+
+
+ dispatcherServlet
+ /
+
+
+
\ No newline at end of file
diff --git a/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/webapp/index.jsp b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/webapp/index.jsp
new file mode 100644
index 000000000..c38169bb9
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-multi-data-ids-example/src/main/webapp/index.jsp
@@ -0,0 +1,5 @@
+
+
+Hello World!
+
+
diff --git a/nacos-spring-example/nacos-spring-config-pojo-example/pom.xml b/nacos-spring-example/nacos-spring-config-pojo-example/pom.xml
new file mode 100644
index 000000000..cbae9186a
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-pojo-example/pom.xml
@@ -0,0 +1,38 @@
+
+
+
+
+ nacos-spring-example
+ com.alibaba.nacos
+ 0.2.0-SNAPSHOT
+
+
+ 4.0.0
+
+ nacos-spring-config-pojo-example
+ pom
+
+ nacos-spring-config-pojo-example
+
+ http://nacos.io
+
+
+
+
+ javax.servlet
+ javax.servlet-api
+
+
+
+ org.springframework
+ spring-webmvc
+
+
+
+ com.alibaba.nacos
+ nacos-spring-context
+ 0.1.0-RC1
+
+
+
diff --git a/nacos-spring-example/nacos-spring-config-pojo-example/src/main/java/com/alibaba/nacos/example/spring/PromotionConfiguration.java b/nacos-spring-example/nacos-spring-config-pojo-example/src/main/java/com/alibaba/nacos/example/spring/PromotionConfiguration.java
new file mode 100644
index 000000000..a746b43fb
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-pojo-example/src/main/java/com/alibaba/nacos/example/spring/PromotionConfiguration.java
@@ -0,0 +1,24 @@
+package com.alibaba.nacos.example.spring;
+
+import com.alibaba.nacos.api.annotation.NacosProperties;
+import com.alibaba.nacos.example.spring.model.Promotion;
+import com.alibaba.nacos.spring.context.annotation.config.EnableNacosConfig;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+// 在命名空间详情处可以获取到 endpoint 和 namespace;accessKey 和 secretKey 推荐使用 RAM 账户的
+@EnableNacosConfig(globalProperties = @NacosProperties(
+ endpoint = "xxx",
+ namespace = "xxx",
+ accessKey = "xxx",
+ secretKey = "xxx"
+))
+public class PromotionConfiguration {
+
+ @Bean
+ public Promotion promotion() {
+ return new Promotion();
+ }
+
+}
\ No newline at end of file
diff --git a/nacos-spring-example/nacos-spring-config-pojo-example/src/main/java/com/alibaba/nacos/example/spring/controller/PromotionController.java b/nacos-spring-example/nacos-spring-config-pojo-example/src/main/java/com/alibaba/nacos/example/spring/controller/PromotionController.java
new file mode 100644
index 000000000..a792b73d8
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-pojo-example/src/main/java/com/alibaba/nacos/example/spring/controller/PromotionController.java
@@ -0,0 +1,25 @@
+package com.alibaba.nacos.example.spring.controller;
+
+import com.alibaba.nacos.example.spring.model.Promotion;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import static org.springframework.web.bind.annotation.RequestMethod.GET;
+
+@Controller
+@RequestMapping("promotion")
+public class PromotionController {
+
+ @Autowired
+ private Promotion promotion;
+
+ @RequestMapping(method = GET)
+ @ResponseBody
+ public Promotion get() {
+ return promotion;
+ }
+
+}
+
diff --git a/nacos-spring-example/nacos-spring-config-pojo-example/src/main/java/com/alibaba/nacos/example/spring/model/Promotion.java b/nacos-spring-example/nacos-spring-config-pojo-example/src/main/java/com/alibaba/nacos/example/spring/model/Promotion.java
new file mode 100644
index 000000000..689f2186f
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-pojo-example/src/main/java/com/alibaba/nacos/example/spring/model/Promotion.java
@@ -0,0 +1,76 @@
+package com.alibaba.nacos.example.spring.model;
+
+import com.alibaba.nacos.api.config.annotation.NacosConfigurationProperties;
+import com.alibaba.nacos.api.config.annotation.NacosIgnore;
+import com.alibaba.nacos.api.config.annotation.NacosProperty;
+
+/**
+ * @author hexu.hxy
+ * @date 2019/1/6
+ *
+ * ACM 控制台添加配置:
+ * Data ID:promotion.properties
+ * Group:spring-example
+ * 配置内容:
+ * sku=1
+ * price=99.9
+ * amount=1000
+ * desc=desc
+ * description=description
+ * sold=99
+ */
+@NacosConfigurationProperties(dataId = "promotion.properties", groupId = "spring-example", autoRefreshed = true)
+public class Promotion {
+
+ private long sku;
+
+ private double price;
+
+ private int amount;
+
+ @NacosProperty(value = "desc")
+ private String description;
+
+ @NacosIgnore
+ private int sold;
+
+ public long getSku() {
+ return sku;
+ }
+
+ public void setSku(long sku) {
+ this.sku = sku;
+ }
+
+ public double getPrice() {
+ return price;
+ }
+
+ public void setPrice(double price) {
+ this.price = price;
+ }
+
+ public int getAmount() {
+ return amount;
+ }
+
+ public void setAmount(int amount) {
+ this.amount = amount;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public int getSold() {
+ return sold;
+ }
+
+ public void setSold(int sold) {
+ this.sold = sold;
+ }
+}
diff --git a/nacos-spring-example/nacos-spring-config-pojo-example/src/main/webapp/WEB-INF/dispatcherServlet-servlet.xml b/nacos-spring-example/nacos-spring-config-pojo-example/src/main/webapp/WEB-INF/dispatcherServlet-servlet.xml
new file mode 100644
index 000000000..2c1a84ae1
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-pojo-example/src/main/webapp/WEB-INF/dispatcherServlet-servlet.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/nacos-spring-example/nacos-spring-config-pojo-example/src/main/webapp/WEB-INF/web.xml b/nacos-spring-example/nacos-spring-config-pojo-example/src/main/webapp/WEB-INF/web.xml
new file mode 100644
index 000000000..2e1696d9b
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-pojo-example/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,17 @@
+
+
+
+
+ dispatcherServlet
+ org.springframework.web.servlet.DispatcherServlet
+ 1
+
+
+
+ dispatcherServlet
+ /
+
+
+
\ No newline at end of file
diff --git a/nacos-spring-example/nacos-spring-config-pojo-example/src/main/webapp/index.jsp b/nacos-spring-example/nacos-spring-config-pojo-example/src/main/webapp/index.jsp
new file mode 100644
index 000000000..c38169bb9
--- /dev/null
+++ b/nacos-spring-example/nacos-spring-config-pojo-example/src/main/webapp/index.jsp
@@ -0,0 +1,5 @@
+
+
+Hello World!
+
+
diff --git a/nacos-spring-example/pom.xml b/nacos-spring-example/pom.xml
index db68d22e9..ae37176dd 100644
--- a/nacos-spring-example/pom.xml
+++ b/nacos-spring-example/pom.xml
@@ -15,6 +15,10 @@
pom
nacos-spring-config-example
+ nacos-spring-config-pojo-example
+ nacos-spring-config-listener-example
+ nacos-spring-config-multi-data-ids-example
+ nacos-spring-config-datasource-example
nacos-spring-discovery-example
@@ -25,7 +29,7 @@
3.2.18.RELEASE
3.0.1
- 0.2.1-RC1
+ 0.2.2-RC1