溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

IDEA怎么用SpringAssistant插件創(chuàng)建SpringCloud項目

發(fā)布時間:2021-06-24 09:04:07 來源:億速云 閱讀:755 作者:chen 欄目:開發(fā)技術

本篇內容主要講解“IDEA怎么用SpringAssistant插件創(chuàng)建SpringCloud項目”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“IDEA怎么用SpringAssistant插件創(chuàng)建SpringCloud項目”吧!

1、配置 IDEA 的 Maven 環(huán)境

單擊菜單欄中的 File → Settings → Build, Execution, Deployment → Build Tools → Maven 菜單,在彈出的設置窗口中設置 Maven 路徑信息,如下圖:

IDEA怎么用SpringAssistant插件創(chuàng)建SpringCloud項目

2、安裝 Spring Assistant 插件

創(chuàng)建 Spring Cloud(Spring Boot)有兩種方式,這里使用 Spring Assistant 插件創(chuàng)建項目。

(1)啟動 IDEA,單擊菜單欄中的 File → Settings → plugins 菜單。

(2)進入界面,在搜索框中輸入關鍵字 “Spring Assistant”,然后按 Enter 鍵,會搜索到 Spring Assistant(Spring 助理)。在 Spring Assistant 的下方點擊 “Install” 按鈕即可完成安裝。如下圖:

IDEA怎么用SpringAssistant插件創(chuàng)建SpringCloud項目

(3)重啟 IDEA 后即可使用。

3、創(chuàng)建 Spring Cloud 項目

下面以創(chuàng)建 Spring Cloud 項目中的基于 Consul 的“服務提供者”為例。

(1)打開 IDEA 開發(fā)工具后,選擇菜單:File → New → Project。

在左邊欄中選擇 Spring Assistant,點擊 “Next” 按鈕。

IDEA怎么用SpringAssistant插件創(chuàng)建SpringCloud項目

(2)輸入項目相關信息,點擊 “Next” 按鈕。

IDEA怎么用SpringAssistant插件創(chuàng)建SpringCloud項目

(3)創(chuàng)建基于 Consul 的“服務提供者”,選擇項如下圖,點擊 “Next” 按鈕。

IDEA怎么用SpringAssistant插件創(chuàng)建SpringCloud項目

(4)項目創(chuàng)建完成,項目結構圖如下:

IDEA怎么用SpringAssistant插件創(chuàng)建SpringCloud項目

打開 pom.xml 文件內容如下:

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.5.1</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.pjb</groupId>
	<artifactId>provider</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>Provider</name>
	<description>Demo project for Spring Boot</description>
	<properties>
		<java.version>11</java.version>
		<spring-cloud.version>2020.0.3</spring-cloud.version>
	</properties>
	<dependencies>
 
		<!-- Spring Cloud Consul 的依賴 -->
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-consul-discovery</artifactId>
		</dependency>
 
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>
	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-dependencies</artifactId>
				<version>${spring-cloud.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>
 
	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>
 
</project>

從 pom.xml 文件中可以看出,Consul 的依賴已經自動添加。

到此,相信大家對“IDEA怎么用SpringAssistant插件創(chuàng)建SpringCloud項目”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續(xù)學習!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經查實,將立刻刪除涉嫌侵權內容。

AI