統合ナコスのケース春ブーツ

1.ナコスは現在、追加するように構成することが

2.springbootプロジェクト統合ナコス

注ナコス、以下に示すように、プロジェクトの別の構成によれば

統合ナコスクライアントパッケージ

 
  1. <dependency>

  2. <groupId>com.alibaba.boot</groupId>

  3. <artifactId>nacos-config-spring-boot-starter</artifactId>

  4. <version>0.1.6</version>

  5. </dependency>

負荷プロファイル

 
  1. /**

  2. *MITLicense

  3. *Copyright(c)2018haihua.liu

  4. *Permissionisherebygranted,freeofcharge,toanypersonobtainingacopy

  5. *ofthissoftwareandassociateddocumentationfiles(the"Software"),todeal

  6. *intheSoftwarewithoutrestriction,includingwithoutlimitationtherights

  7. *touse,copy,modify,merge,publish,distribute,sublicense,and/orsell

  8. *copiesoftheSoftware,andtopermitpersonstowhomtheSoftwareis

  9. *furnishedtodoso,subjecttothefollowingconditions:

  10. *Theabovecopyrightnoticeandthispermissionnoticeshallbeincludedinall

  11. *copiesorsubstantialportionsoftheSoftware.

  12. *THESOFTWAREISPROVIDED"ASIS",WITHOUTWARRANTYOFANYKIND,EXPRESSOR

  13. *IMPLIED,INCLUDINGBUTNOTLIMITEDTOTHEWARRANTIESOFMERCHANTABILITY,

  14. *FITNESSFORAPARTICULARPURPOSEANDNONINFRINGEMENT.INNOEVENTSHALLTHE

  15. *AUTHORSORCOPYRIGHTHOLDERSBELIABLEFORANYCLAIM,DAMAGESOROTHER

  16. *LIABILITY,WHETHERINANACTIONOFCONTRACT,TORTOROTHERWISE,ARISINGFROM,

  17. *OUTOFORINCONNECTIONWITHTHESOFTWAREORTHEUSEOROTHERDEALINGSINTHE

  18. *SOFTWARE.

  19. */

  20. packagecn.liuhaihua.web;

  21.  

  22. importcn.liuhaihua.web.mapper.BaseMapper;

  23. importcom.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;

  24. importorg.mybatis.spring.annotation.MapperScan;

  25. importorg.springframework.boot.SpringApplication;

  26. importorg.springframework.boot.autoconfigure.SpringBootApplication;

  27. importorg.springframework.boot.web.servlet.ServletComponentScan;

  28. importorg.springframework.transaction.annotation.EnableTransactionManagement;

  29.  

  30. /**

  31. *@ClassName:JWordpressWebApplication

  32. *@Description:Springboot应用程序启动类

  33. *@authorLiuhaihua

  34. *@date2018年6月26日

  35. *

  36. */

  37. @SpringBootApplication

  38. @ServletComponentScan

  39. @EnableTransactionManagement

  40. @MapperScan(basePackages="cn.liuhaihua.web.*",markerInterface=BaseMapper.class)

  41. @NacosPropertySource(dataId="web",autoRefreshed=true)

  42. publicclassJWordpressWebApplication{

  43.  

  44. /**

  45. *@Title:main

  46. *@Description:main启动方法

  47. *@param@paramargs

  48. *@returnvoid

  49. *@throws

  50. */

  51. publicstaticvoidmain(String[]args){

  52. SpringApplication.run(JWordpressWebApplication.class,args);

  53. System.out.println("JWordpressWebApplication启动成功");

  54.  

  55. }

  56.  

  57. }

主なコードは次のとおりです。

 
  1. @NacosPropertySource(dataId="web",autoRefreshed=true)

ナコスの終わりにあなたのサービスの構成にデータID =「ウェブ」対応

あなたは異なる環境を区別したい場合は、(開発/テスト/本番)が必要と名前空間と相まって、

application.properties

  •  
spring.profiles.active=develop

application-develop.properties

 
  1. nacos.config.server-addr=10.42.226.203:8848

  2. nacos.config.namespace=39a58908-d8af-4816-b87d-c964aa8cbaf2

テストを開始します。

説明は、設定ファイルで成功をロードすることができます

 

読み取り後のJavaの雑多、。

公開された306元の記事 ウォン称賛67 ビュー380 000 +

おすすめ

転載: blog.csdn.net/ailiandeziwei/article/details/105239299