مقدمة
في الأنظمة الموزعة ، نظرًا للعدد الهائل من الخدمات ، من أجل تسهيل الإدارة الموحدة لملفات تكوين الخدمة والتحديثات في الوقت الفعلي ، فإن مكون مركز التكوين الموزع: مطلوب مكون من السحابة النابضة. وهو يدعم خدمات التكوين الواجب وضعها في ذكرى خدمة التكوين (أي المحلية) ، ويدعم أيضًا التنسيب في مستودع GIT عن بُعد.
يوضح هذا القسم بشكل أساسي كيفية استخدام مستودع GIT كمصدر للتكوين.
عنوان مفتوح المصدر: https://github.com/bigbeef
إنشاء مشروع تكوين
قم بإنشاء مشروع في GitHub خصيصًا لحفظ ملفات التكوين لجميع مشاريعنا. المشروع هو بنية مشروعي
عنوان مشروع التكوين: https://github.com/bigbeef/cppba-config
eureka-server.properties
eureka.client.register-with-eureka = passeureka.client.fetch-registry = falspring.application.name = eureka-serverserver
قم بإنشاء مشروع خادم من الربيع السحابي
يظهر هيكل المشروع في الشكل:
POM.XML CORE CODE
<ependencies> <Rependency> <roupiD> org.springframework.cloud </groupId> <StifactId> spring-cloud-config-server </shintifactid> </reperence> </sependencies>
SpringCloudConfigServerApplication.java
حزمة com.cppba ؛ استيراد org.springframework.boot.springapplication ؛ استيراد org.springframework.boot.autoconfigure.springbootapplication SpringCloudConfigServerApplication {public static void main (string [] args) {springapplication.run (springCloudConfigServerApplication.class ، args) ؛ }}application.properties
يعتمد هذا على مشروع GIT الفعلي الخاص بك
server.port = 8888spring.application.name = config-serverspring.cloud.config.server.git.uri = https: //github.com/bigbeef/cppba-configspring.cloud.config.label=master# spring.cloud.server.git.git.git.git.git.git.s spring.cloud.config.server.git.password = spring.cloud.config.server.git.searchpaths =/cppba-spring-cloud/*،/cppba-spring-cloud/eureka-client/**
spring.cloud.config.server.git.uri: تكوين عنوان مستودع GIT
spring.cloud.config.server.git.searchpaths: تكوين مسار المستودع ، مفصولة بفواصل
spring.cloud.config.label: تكوين فرع المستودع
spring.cloud.config.server.git.username: اسم المستخدم للوصول إلى مستودع GIT
spring.cloud.config.server.git.password: كلمة مرور المستخدم للوصول إلى مستودع GIT
ابدأ المشروع
عنوان الوصول: http://127.0.0.1:8888
عنوان طلب HTTP ورسم خرائط ملفات الموارد كما يلي:
/{application}/{profile} [/{label}]
/{application)-{profile ).yml
/{label )/ {application )- {profile ).yml
/{application)-{profile ).properties
/{label )/ {application )- {profile ).properties
وفقًا لتكويننا الخاص ، يمكننا الوصول إليه على هذا النحو: http://127.0.0.1:8888/eureka-server/default/master
التطبيق -> eureka -server (اسم التطبيق)
ملف تعريف -> افتراضي (تكوين ممكّن ، عادةً لاحقة ، موضحة أدناه)
Label -> Master (Branch)
نتيجة الزيارة هي:
الملف الشخصي أكثر أهمية ، يمكن فهمه على أنه قراءة ملفات التكوين. إذا كان لدي أكثر من ملف تكوين واحد ، فقد يكون هناك:
eureka-server.properties (هذا ملف تكوين عام وسيتم تحميله افتراضيًا) ،
eureka-server-mysql.properties ،
eureka-server-oracle.properties ،
eureka-server-jpa.properties ،
eureka-server-mysql.properties ......
يجوز لنا بشكل انتقائي تحميل بعض ملفات تكوين الخصائص فيه ، حتى نتمكن من كتابتها مثل هذا: http://127.0.0.1:8888/eureka-server/default
في هذه المرحلة ، يتم إعداد خادم نهر السحابة الربيع ببساطة. في الفصول التالية ، سأعلمك كيفية قراءة التكوينات في المشروع.
ما سبق هو كل محتوى هذه المقالة. آمل أن يكون ذلك مفيدًا لتعلم الجميع وآمل أن يدعم الجميع wulin.com أكثر.