Config配置中心配置完成

This commit is contained in:
YoVinchen 2023-08-16 09:17:04 +08:00
parent c1bcb68295
commit f70821bacb
8 changed files with 88 additions and 6 deletions

View File

@ -19,6 +19,15 @@
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>

View File

@ -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);

View File

@ -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:

View File

@ -0,0 +1,11 @@
spring:
cloud:
config:
# 名称,其实就是文件名称
name: bookservice
# 配置服务器的地址
uri: http://localhost:8700
# 环境
profile: prod
# 分支
label: master

30
config-service/pom.xml Normal file
View File

@ -0,0 +1,30 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.example</groupId>
<artifactId>SpringCloudStudy</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<groupId>org.example</groupId>
<artifactId>config-service</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -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);
}
}

View File

@ -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

View File

@ -22,6 +22,7 @@
<module>eureka-service</module>
<module>hystrix-dashboard</module>
<module>gateway-service</module>
<module>config-service</module>
</modules>
<properties>
<java.version>1.8</java.version>