1.ナコスは現在、追加するように構成することが
2.springbootプロジェクト統合ナコス
注ナコス、以下に示すように、プロジェクトの別の構成によれば
統合ナコスクライアントパッケージ
-
<dependency>
-
<groupId>com.alibaba.boot</groupId>
-
<artifactId>nacos-config-spring-boot-starter</artifactId>
-
<version>0.1.6</version>
-
</dependency>
負荷プロファイル
-
/**
-
*MITLicense
-
*Copyright(c)2018haihua.liu
-
*Permissionisherebygranted,freeofcharge,toanypersonobtainingacopy
-
*ofthissoftwareandassociateddocumentationfiles(the"Software"),todeal
-
*intheSoftwarewithoutrestriction,includingwithoutlimitationtherights
-
*touse,copy,modify,merge,publish,distribute,sublicense,and/orsell
-
*copiesoftheSoftware,andtopermitpersonstowhomtheSoftwareis
-
*furnishedtodoso,subjecttothefollowingconditions:
-
*Theabovecopyrightnoticeandthispermissionnoticeshallbeincludedinall
-
*copiesorsubstantialportionsoftheSoftware.
-
*THESOFTWAREISPROVIDED"ASIS",WITHOUTWARRANTYOFANYKIND,EXPRESSOR
-
*IMPLIED,INCLUDINGBUTNOTLIMITEDTOTHEWARRANTIESOFMERCHANTABILITY,
-
*FITNESSFORAPARTICULARPURPOSEANDNONINFRINGEMENT.INNOEVENTSHALLTHE
-
*AUTHORSORCOPYRIGHTHOLDERSBELIABLEFORANYCLAIM,DAMAGESOROTHER
-
*LIABILITY,WHETHERINANACTIONOFCONTRACT,TORTOROTHERWISE,ARISINGFROM,
-
*OUTOFORINCONNECTIONWITHTHESOFTWAREORTHEUSEOROTHERDEALINGSINTHE
-
*SOFTWARE.
-
*/
-
packagecn.liuhaihua.web;
-
-
importcn.liuhaihua.web.mapper.BaseMapper;
-
importcom.alibaba.nacos.spring.context.annotation.config.NacosPropertySource;
-
importorg.mybatis.spring.annotation.MapperScan;
-
importorg.springframework.boot.SpringApplication;
-
importorg.springframework.boot.autoconfigure.SpringBootApplication;
-
importorg.springframework.boot.web.servlet.ServletComponentScan;
-
importorg.springframework.transaction.annotation.EnableTransactionManagement;
-
-
/**
-
*@ClassName:JWordpressWebApplication
-
*@Description:Springboot应用程序启动类
-
*@authorLiuhaihua
-
*@date2018年6月26日
-
*
-
*/
-
@SpringBootApplication
-
@ServletComponentScan
-
@EnableTransactionManagement
-
@MapperScan(basePackages="cn.liuhaihua.web.*",markerInterface=BaseMapper.class)
-
@NacosPropertySource(dataId="web",autoRefreshed=true)
-
publicclassJWordpressWebApplication{
-
-
/**
-
*@Title:main
-
*@Description:main启动方法
-
*@param@paramargs
-
*@returnvoid
-
*@throws
-
*/
-
publicstaticvoidmain(String[]args){
-
SpringApplication.run(JWordpressWebApplication.class,args);
-
System.out.println("JWordpressWebApplication启动成功");
-
-
}
-
-
}
主なコードは次のとおりです。
-
@NacosPropertySource(dataId="web",autoRefreshed=true)
ナコスの終わりにあなたのサービスの構成にデータID =「ウェブ」対応
あなたは異なる環境を区別したい場合は、(開発/テスト/本番)が必要と名前空間と相まって、
application.properties
spring.profiles.active=develop
application-develop.properties
-
nacos.config.server-addr=10.42.226.203:8848
-
nacos.config.namespace=39a58908-d8af-4816-b87d-c964aa8cbaf2
テストを開始します。
説明は、設定ファイルで成功をロードすることができます
読み取り後のJavaの雑多、。