diff --git a/book-service/pom.xml b/book-service/pom.xml index 23f9cbc..5415f65 100644 --- a/book-service/pom.xml +++ b/book-service/pom.xml @@ -19,6 +19,15 @@ + + org.springframework.cloud + spring-cloud-starter-config + + + + org.springframework.cloud + spring-cloud-starter-bootstrap + org.springframework.cloud spring-cloud-starter-netflix-eureka-client diff --git a/book-service/src/main/java/com/test/BookApplication.java b/book-service/src/main/java/com/test/BookApplication.java index ee58ebd..9575210 100644 --- a/book-service/src/main/java/com/test/BookApplication.java +++ b/book-service/src/main/java/com/test/BookApplication.java @@ -12,7 +12,6 @@ import org.springframework.cloud.netflix.eureka.EnableEurekaClient; * @Create 2023/8/14 16:23 */ @SpringBootApplication -@EnableEurekaClient public class BookApplication { public static void main(String[] args) { SpringApplication.run(BookApplication.class,args); diff --git a/book-service/src/main/resources/application.yml b/book-service/src/main/resources/application.yml index ecec898..2adeada 100644 --- a/book-service/src/main/resources/application.yml +++ b/book-service/src/main/resources/application.yml @@ -3,11 +3,6 @@ server: spring: application: name: bookservice - datasource: - driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://43.143.164.194:3306/mac - username: mac - password: mactest eureka: client: serviceUrl: diff --git a/book-service/src/main/resources/bootstrap.yml b/book-service/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..644d749 --- /dev/null +++ b/book-service/src/main/resources/bootstrap.yml @@ -0,0 +1,11 @@ +spring: + cloud: + config: + # 名称,其实就是文件名称 + name: bookservice + # 配置服务器的地址 + uri: http://localhost:8700 + # 环境 + profile: prod + # 分支 + label: master diff --git a/config-service/pom.xml b/config-service/pom.xml new file mode 100644 index 0000000..490f8e5 --- /dev/null +++ b/config-service/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + + com.example + SpringCloudStudy + 0.0.1-SNAPSHOT + + + org.example + config-service + + + 8 + 8 + UTF-8 + + + + org.springframework.cloud + spring-cloud-config-server + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + + + diff --git a/config-service/src/main/java/com/test/ConfigApplication.java b/config-service/src/main/java/com/test/ConfigApplication.java new file mode 100644 index 0000000..b444be0 --- /dev/null +++ b/config-service/src/main/java/com/test/ConfigApplication.java @@ -0,0 +1,20 @@ +package com.test; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.config.server.EnableConfigServer; + +/** + * ClassName: ConfigApplication + * Package: com.test + * + * @author yovinchen + * @Create 2023/8/16 09:06 + */ +@SpringBootApplication +@EnableConfigServer +public class ConfigApplication { + public static void main(String[] args) { + SpringApplication.run(ConfigApplication.class, args); + } +} diff --git a/config-service/src/main/resources/application.yml b/config-service/src/main/resources/application.yml new file mode 100644 index 0000000..cd1f2e6 --- /dev/null +++ b/config-service/src/main/resources/application.yml @@ -0,0 +1,17 @@ +server: + port: 8700 +spring: + cloud: + config: + server: + git: + # 这里填写的是本地仓库地址,远程仓库直接填写远程仓库地址 http://git... + uri: file://${user.home}/project/Java/demo/config-repo + # 默认分支设定为你自己本地或是远程分支的名称 + default-label: master + application: + name: configservice +eureka: + client: + service-url: + defaultZone: http://localhost:8801/eureka, http://localhost:8802/eureka diff --git a/pom.xml b/pom.xml index b13633e..0875efb 100644 --- a/pom.xml +++ b/pom.xml @@ -22,6 +22,7 @@ eureka-service hystrix-dashboard gateway-service + config-service 1.8