File tree Expand file tree Collapse file tree 4 files changed +176
-0
lines changed
java/com/didispace/chapter13 Expand file tree Collapse file tree 4 files changed +176
-0
lines changed Original file line number Diff line number Diff line change 1+ HELP.md
2+ /target /
3+ ! .mvn /wrapper /maven-wrapper.jar
4+
5+ # ## STS ###
6+ .apt_generated
7+ .classpath
8+ .factorypath
9+ .project
10+ .settings
11+ .springBeans
12+ .sts4-cache
13+
14+ # ## IntelliJ IDEA ###
15+ .idea
16+ * .iws
17+ * .iml
18+ * .ipr
19+
20+ # ## NetBeans ###
21+ /nbproject /private /
22+ /nbbuild /
23+ /dist /
24+ /nbdist /
25+ /.nb-gradle /
26+ /build /
27+
28+ # ## VS Code ###
29+ .vscode /
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <project xmlns =" http://maven.apache.org/POM/4.0.0" xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
3+ xsi:schemaLocation=" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" >
4+ <modelVersion >4.0.0</modelVersion >
5+ <parent >
6+ <groupId >org.springframework.boot</groupId >
7+ <artifactId >spring-boot-starter-parent</artifactId >
8+ <version >2.4.1</version >
9+ <relativePath /> <!-- lookup parent from repository -->
10+ </parent >
11+ <groupId >com.didispace</groupId >
12+ <artifactId >chapter1-3</artifactId >
13+ <version >0.0.1-SNAPSHOT</version >
14+ <name >chapter1-3</name >
15+ <description >Demo project for Spring Boot</description >
16+
17+ <properties >
18+ <java .version>1.8</java .version>
19+ </properties >
20+
21+ <dependencies >
22+ <dependency >
23+ <groupId >org.springframework.boot</groupId >
24+ <artifactId >spring-boot-starter-web</artifactId >
25+ </dependency >
26+
27+ <dependency >
28+ <groupId >org.projectlombok</groupId >
29+ <artifactId >lombok</artifactId >
30+ <scope >provided</scope >
31+ </dependency >
32+
33+ <dependency >
34+ <groupId >org.springframework.boot</groupId >
35+ <artifactId >spring-boot-starter-test</artifactId >
36+ <scope >test</scope >
37+ </dependency >
38+ </dependencies >
39+
40+ <build >
41+ <plugins >
42+ <plugin >
43+ <groupId >org.springframework.boot</groupId >
44+ <artifactId >spring-boot-maven-plugin</artifactId >
45+ </plugin >
46+ </plugins >
47+ </build >
48+
49+ </project >
Original file line number Diff line number Diff line change 1+ package com .didispace .chapter13 ;
2+
3+ import lombok .extern .slf4j .Slf4j ;
4+ import org .springframework .beans .factory .annotation .Value ;
5+ import org .springframework .boot .SpringApplication ;
6+ import org .springframework .boot .autoconfigure .SpringBootApplication ;
7+ import org .springframework .web .bind .annotation .RequestMapping ;
8+ import org .springframework .web .bind .annotation .RestController ;
9+
10+
11+ @ SpringBootApplication
12+ public class Chapter13Application {
13+
14+ public static void main (String [] args ) {
15+ SpringApplication .run (Chapter13Application .class , args );
16+ }
17+
18+ @ Slf4j
19+ @ RestController
20+ static class HelloController {
21+
22+ @ Value ("${db:}" )
23+ private String db ;
24+
25+ @ Value ("${mq:}" )
26+ private String mq ;
27+
28+ @ RequestMapping ("/" )
29+ public String index () {
30+ log .info ("db:" + db );
31+ log .info ("mq:" + mq );
32+ return "" ;
33+ }
34+
35+ }
36+
37+ }
Original file line number Diff line number Diff line change 1+ # 2.4之前的配置
2+ # spring:
3+ # profiles:
4+ # active: "dev"
5+ #
6+ # ---
7+ # spring.profiles: "dev"
8+ # spring.profiles.include: "dev-db,dev-mq"
9+ #
10+ # ---
11+ # spring.profiles: "dev-db"
12+ #
13+ # db: dev-db.didispace.com
14+ #
15+ # ---
16+ # spring.profiles: "dev-mq"
17+ #
18+ # mq: dev-mq.didispace.com
19+ #
20+ # ---
21+
22+ # 2.4之后的配置
23+ # 默认激活dev配置
24+ spring :
25+ profiles :
26+ active : " dev"
27+ group :
28+ " dev " : " dev-db,dev-mq"
29+ " prod " : " prod-db,prod-mq"
30+
31+ ---
32+ spring :
33+ config :
34+ activate :
35+ on-profile : " dev-db"
36+
37+ db : dev-db.didispace.com
38+
39+ ---
40+ spring :
41+ config :
42+ activate :
43+ on-profile : " dev-mq"
44+
45+ mq : dev-mq.didispace.com
46+
47+ ---
48+ spring :
49+ config :
50+ activate :
51+ on-profile : " prod-db"
52+
53+ db : prod-db.didispace.com
54+
55+ ---
56+ spring :
57+ config :
58+ activate :
59+ on-profile : " prod-mq"
60+
61+ mq : prod-mq.didispace.com
You can’t perform that action at this time.
0 commit comments