forked from wuyouzhuguli/SpringAll
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
2d19bbe
commit a1d8d72
Showing
5 changed files
with
130 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>2.2.5.RELEASE</version> | ||
<relativePath/> <!-- lookup parent from repository --> | ||
</parent> | ||
|
||
<groupId>cc.mrbird</groupId> | ||
<artifactId>spring-cloud-alibaba-nacos-config</artifactId> | ||
<version>0.0.1-SNAPSHOT</version> | ||
<name>spring-cloud-alibaba-nacos-config</name> | ||
<description>Demo project for Spring Boot</description> | ||
|
||
<properties> | ||
<java.version>1.8</java.version> | ||
<spring-cloud.version>Hoxton.SR3</spring-cloud.version> | ||
<com-alibaba-cloud.version>2.2.0.RELEASE</com-alibaba-cloud.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba.cloud</groupId> | ||
<artifactId>spring-cloud-alibaba-nacos-config</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-dependencies</artifactId> | ||
<version>${spring-cloud.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.alibaba.cloud</groupId> | ||
<artifactId>spring-cloud-alibaba-dependencies</artifactId> | ||
<version>${com-alibaba-cloud.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
13 changes: 13 additions & 0 deletions
13
...-nacos-config/src/main/java/cc/mrbird/nacos/SpringCloudAlibabaNacosConfigApplication.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,13 @@ | ||
package cc.mrbird.nacos; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
@SpringBootApplication | ||
public class SpringCloudAlibabaNacosConfigApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(SpringCloudAlibabaNacosConfigApplication.class, args); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
...g-cloud-alibaba-nacos-config/src/main/java/cc/mrbird/nacos/controller/TestController.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,31 @@ | ||
package cc.mrbird.nacos.controller; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.cloud.context.config.annotation.RefreshScope; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
/** | ||
* @author MrBird | ||
*/ | ||
@RestController | ||
@RefreshScope | ||
public class TestController { | ||
|
||
@Value("${message:null}") | ||
private String message; | ||
@Value("${ext1:null}") | ||
private String ext1; | ||
@Value("${ext2:null}") | ||
private String ext2; | ||
|
||
@GetMapping("message") | ||
public String getMessage() { | ||
return this.message; | ||
} | ||
|
||
@GetMapping("multi") | ||
public String multiConfig() { | ||
return String.format("ext1: %s ext2: %s", ext1, ext2); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
75.spring-cloud-alibaba-nacos-config/src/main/resources/application.yml
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,5 @@ | ||
server: | ||
port: 8080 | ||
spring: | ||
application: | ||
name: my-project |
19 changes: 19 additions & 0 deletions
19
75.spring-cloud-alibaba-nacos-config/src/main/resources/bootstrap.yml
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,19 @@ | ||
spring: | ||
# profiles: | ||
# active: dev | ||
cloud: | ||
nacos: | ||
config: | ||
server-addr: localhost:8848 | ||
# file-extension: yaml | ||
# prefix: febs | ||
# namespace: '2ef2186e-078c-4904-8643-ff5e90555456' | ||
# group: GROUP_A | ||
# extension-configs: | ||
# - dataId: ext-config-one.yaml | ||
# group: DEFAULT_GROUP | ||
# refresh: true | ||
# - dataId: ext-config-one.yaml | ||
# group: DEFAULT_GROUP | ||
# refresh: false | ||
shared-configs: ext-config-one.yaml,ext-config-two.yaml |