Skip to content

Commit

Permalink
feat(ms-init): 完善config, gateway, business module中配置文件的问题 #174
Browse files Browse the repository at this point in the history
  • Loading branch information
zhonghuasheng committed Dec 30, 2020
1 parent 63f2bc6 commit d00d2c5
Show file tree
Hide file tree
Showing 14 changed files with 24 additions and 13 deletions.
4 changes: 2 additions & 2 deletions musicstore-springboot-vue/ms-platform/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class UserApplication {

public static void main(String[] args) {
YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
yaml.setResources(new ClassPathResource("application.yml"));
yaml.setResources(new ClassPathResource("bootstrap.yml"));
Properties property = yaml.getObject();
System.setProperty("SERVICE_NAME", property.getProperty("spring.application.name"));
System.setProperty("FILE_PATH", property.getProperty("logging.file.path"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ spring:
time-between-log-stats-millis: 30000
cloud:
nacos:
config:
server-addr: ${ms.nacos.host}
discovery:
server-addr: localhost:8848
server-addr: ${ms.nacos.host}
mybatis-plus:
type-aliases-package: com.zhonghuasheng.ms.model
logging:
Expand Down
4 changes: 4 additions & 0 deletions musicstore-springboot-vue/ms-platform/ms-business/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.zhonghuasheng</groupId>
<artifactId>ms-config</artifactId>
</dependency>
</dependencies>

<modules>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ms.env.name=dev

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ms.env.name=prod

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
spring.profiles.active=dev

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ms.nacos.host=192.168.88.127:8848
4 changes: 4 additions & 0 deletions musicstore-springboot-vue/ms-platform/ms-gateway/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,9 @@
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>2.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>com.zhonghuasheng</groupId>
<artifactId>ms-config</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class GatewayApplication {

public static void main(String[] args) {
YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
yaml.setResources(new ClassPathResource("application.yml"));
yaml.setResources(new ClassPathResource("bootstrap.yml"));
Properties property = yaml.getObject();
System.setProperty("SERVICE_NAME", property.getProperty("spring.application.name"));
System.setProperty("FILE_PATH", property.getProperty("logging.file.path"));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
server:
port: 8888
# nacos是优先启动的,properties配置优先于yml,故我在config中配置了bootstrap.properties中。同时gateway的配置文件也改为比config的application-x
# 优先级高的bootstrap.yml否则,config中的application-x.properties优先启动,然而那里面没有配置nacos的信息,导致前面会报错
spring:
application:
name: ms-gateway
cloud:
nacos:
config:
server-addr: ${ms.nacos.host}
discovery:
server-addr: localhost:8848
server-addr: ${ms.nacos.host}
gateway:
discovery:
locator:
Expand Down

0 comments on commit d00d2c5

Please sign in to comment.