【技術研究】springboot+vue爬坑指南-2020.5.13

最真實的技術研究記錄全過程

B站看了下vue教程,兩倍速+拖動快速預覽後,發現基本環境在之前測試小程序開發流程時已經安裝完畢了,於是找了一篇介紹springboot+vue框架搭建的博客(Springboot Vue Login(從零開始實現Springboot+Vue登錄)

瀏覽了一下之後,下載了vue和springboot的代碼。

運行vscode,加載vue代碼,運行的時候報錯

vue-cli-service' 不是內部或外部命令,也不是可運行的程序或批處理文件

查了一下原因,下載的項目需要在本地npm環境中重新install。cmd命令行模式進行項目文件夾,輸入npm install,然後開始執行,繼續報錯。

Module build failed (from ./node_modules/sass-loader/lib/loader.js):
Error: Cannot find module 'node-sass'

在npm下安裝一個淘寶鏡像npm install -g cnpm --registry=https://registry.npm.taobao.org

然後用cnpm下載最新的node-sass,代碼cnpm install node-sass@latest
,重新在vscode中,terminal-run task。成功彈出登錄頁面

在這裏插入圖片描述

vue項目運行成功,下面開始運行springboot項目。

還是之前的博客,博主很好心的後面有git鏈接,直接下載,然後idea加載。第一次會有些慢,需要導入maven相關依賴。
在這裏插入圖片描述

發現pom.xml報錯。

Project 'org.springframework.boot:spring-boot-starter-parent:2.2.2.RELEASE' not found

多次執行maven install後,該pom文件的依賴始終無法下載。

於是在pom文件中,增加阿里的代理信息

<repositories>
		<repository>
			<id>aliyunmaven</id>
			<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
		</repository>
	</repositories>

再次運行maven install,發現原有的2.2.5.RELEASE已經從紅色變爲黑色。

然後繼續報錯

Plugin org.springframework.boot:spring-boot-maven-plugin:2.2.5.RELEASE or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.springframework.boot:spring-boot-maven-plugin:jar:2.2.5.RELEASE: Could not transfer artifact org.springframework.boot:spring-boot-maven-plugin:pom:2.2.5.RELEASE from/to central (http://repo.maven.apache.org/maven2): Failed to transfer file: http://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-maven-plugin/2.2.5.RELEASE/spring-boot-maven-plugin-2.2.5.RELEASE.pom. Return code is: 501 , ReasonPhrase:HTTPS Required. -> [Help 1]

在maven的.m2文件夾下找到setting.xml,然後把下面的話複製進去。

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
	<mirrors>
		<mirror>
		  <id>mirrorId</id>
		  <mirrorOf>central</mirrorOf>
		  <name>Human Readable Name for this Mirror.</name>
		  <url>http://maven.aliyun.com/nexus/content/groups/public</url>
		</mirror>
	</mirrors> 
</settings>

使用阿里雲的代理下載pom文件。問題解決。
在這裏插入圖片描述

真是不容易,第一個springBoot+vue的例子,終於跑起來了。

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