基於微服務的系統搭建-簡介

主要內容

1. 項目構建思想

項目具體的構建思想是底層技術和業務低耦合。具體是將微服務依賴的服務中心和業務邏輯分爲兩個工程創建。微服務依賴主要包括配置中心,集羣式服務註冊中心,服務監控,服務跟蹤模塊等。業務實現使用其他工程創建,具體也是使用模塊化,此處的模塊化是將控制器,業務邏輯,數據映射分爲三個模塊。這裏主要是介紹一下項目的思想。文中使用的代碼不是全部的構建代碼

2. 微服務父級工程配置

微服務每個工程模塊均依賴一個父級可以減少很多版本不匹配造成的困擾。在父級pom中指定使用的SpringBoot和SpringCloud版本。
如下:

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.4.4.RELEASE</version>
	</parent>

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-dependencies</artifactId>
				<version>Camden.SR5</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

項目依賴的公共jar包可以放到<dependencies>中,這裏我們主要使用springboot-starter構建基於springboot的應用。如下:

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

之後我們構建模塊時就不必引入上述依賴。中管理了springcloud版本,當我們使用springcloud的模塊的時候不必指定版本號。

END

之後會依次介紹如何構建服務配置中心,服務註冊中心等模塊。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章