如何使用win10內(nèi)置的linux系統(tǒng)啟動(dòng)spring-boot項(xiàng)目
1.安裝win10內(nèi)置linux子系統(tǒng)
1.1.安裝linux子系統(tǒng)
1.1.1.升級(jí)或者重裝linux系統(tǒng)
1.系統(tǒng)要求
需要升級(jí)win10到一周年紀(jì)念版,或者 重裝系統(tǒng)
2.重裝系統(tǒng)
筆者結(jié)果測(cè)試發(fā)現(xiàn)下面的系統(tǒng)重裝后可以啟用linux子系統(tǒng)
cn_windows_10_enterprise_version_1607_updated_jul_2016_x64_dvd_9057083.iso
cn_windows_10_multi-edition_vl_version_1709_updated_sept_2017_x64_dvd_100090774.iso
1.1.2.啟用linux子系統(tǒng)
step1.啟用開(kāi)發(fā)人員模式
(16215版之后不再需要開(kāi)發(fā)人員模式)
設(shè)置-->更新和安全-->針對(duì)開(kāi)發(fā)人員

step2.啟用linux子系統(tǒng)
控制面板-->程序和功能-->啟用或關(guān)閉windows功能

1.1.3.在線(xiàn)安裝ubuntu系統(tǒng)
打開(kāi)Microsoft Store安裝ubuntu系統(tǒng)

1.1.4.離線(xiàn)安裝ubuntu系統(tǒng)
下載安裝包,下載自己想要安裝的Linux系統(tǒng)。
參考鏈接:https://docs.microsoft.com/en...
下載Ubuntu 16.04.
Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1604 -OutFile Ubuntu.appx -UseBasicParsing
也可以使用curl下載,但是需要先安裝curl
curl.exe -L -o ubuntu-1604.appx https://aka.ms/wsl-ubuntu-1604
安裝
Add-AppxPackage .\app_name.appx
1.1.5.啟動(dòng)ubuntu系統(tǒng)
啟動(dòng)ubuntu系統(tǒng)
安裝完成后打開(kāi)搜索菜單,輸入系統(tǒng)名字搜索啟動(dòng)

輸出需要設(shè)置的用戶(hù)和密碼

你相信嗎,僅僅只有15.4MB

安裝目錄
C:\Users\Administrator\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc
home目錄
C:\Users\Administrator\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\rootfs\home
1.2.開(kāi)啟ssh-server
1.2.1.相互復(fù)制文件
ubuntu的bash窗口窗與在xshell不同,通過(guò)shift+v無(wú)法黏貼,并且在輸入界面鼠標(biāo)右鍵無(wú)法使用。粘貼文件的方法如下
右擊標(biāo)題欄==> Edit(編輯) ==> Mark/Paste(標(biāo)記并復(fù)制/粘貼)操作

這樣還是很麻煩,可以調(diào)整對(duì)話(huà)框,在彈出的菜單中有一個(gè)Properties對(duì)話(huà)框?qū)傩圆藛?,點(diǎn)擊進(jìn)入下圖

勾選快速編輯、快速插入模式,這兩種模式支持鼠標(biāo)右鍵選中,左鍵黏貼操作。
最后,最好的方式是,在ubuntu上啟動(dòng)ssh服務(wù),通過(guò)xshell連接上操作會(huì)更好。
1.2.2.修改apt源
參考鏈接
https://developer.aliyun.com/...
用你熟悉的編輯器打開(kāi):
/etc/apt/sources.list
替換默認(rèn)的archive.ubuntu.com為mirrors.aliyun.com
修改后的內(nèi)容
ubuntu18.04
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
ubuntu 20.04(focal)
deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiversedeb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
更新
apt-get update
1.2.3.啟用ssh
1.安裝ssh
apt-get -y install openssh-server
2.修改配置文件,一般不需要修改
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak vi /etc/ssh/sshd_config
# 修改端口號(hào),避免和 Windows ssh 服務(wù)端口沖突 Port 2222 #StrictModes yes # 注釋 # 使用密碼登錄 PasswordAuthentication yes # 允許使用 root 用戶(hù)登錄 PermitRootLogin yes
3.設(shè)置root賬號(hào)密碼
sudo -s passwd root
4.啟動(dòng)ssh
service ssh start
5.如果提示“sshd error: could not load host key”,則用下面的命令重新生成
rm /etc/ssh/ssh*key dpkg-reconfigure openssh-server
使用xshell連接127.0.0.1輸入賬號(hào)和密碼即可
1.2.4.配置PS1變量
自行百度什么事linux的PS1變量
export PS1="\[\e[1;32;40m\][\u@\h \W]\\$ \[\e[m\]"
2.搭建開(kāi)發(fā)環(huán)境
2.1.搭建java開(kāi)發(fā)環(huán)境
2.1.1.安裝java和maven
mkdir /usr/java tar -xf jdk-8u211-linux-x64.tar.gz -C /usr/java/ mdkir /usr/maven tar -xf litongjava-apache-maven-3.3.9.tar.gz -C /usr/maven/
配置環(huán)境變量
export JAVA_HOME=/usr/java/jdk1.8.0_211 export M2_HOME=/usr/maven/apache-maven-3.3.9 export PATH=$JAVA_HOME/bin:$M2_HOME/bin:$PATH
配置maven使用windows的maven本地庫(kù)目錄,maven本地庫(kù)在linux中對(duì)應(yīng)的目錄是/mnt/d/dev_mavenRepository/
settings.xml的內(nèi)容如下
cat /usr/maven/apache-maven-3.3.9/conf/settings.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"> <localRepository>/mnt/d/dev_mavenRepository/</localRepository> <pluginGroups> </pluginGroups> <proxies> </proxies> <servers> </servers> <mirrors> <mirror> <id>aliyun</id> <name>aliyun</name> <mirrorOf>*</mirrorOf> <url>https://maven.aliyun.com/repository/public</url> </mirror> </mirrors> <profiles> </profiles> </settings>
2.1.2.打包和啟動(dòng)spring-boot項(xiàng)目
進(jìn)行項(xiàng)目目錄執(zhí)行下面的命令打包項(xiàng)目
mvn clean package -DskipTests
進(jìn)入target目錄啟動(dòng)項(xiàng)目
cd target/
java -jar *.jar
可以明顯的看出,java程序使用了近1G的內(nèi)存

總結(jié)
到此這篇關(guān)于如何使用win10內(nèi)置的linux系統(tǒng)啟動(dòng)spring-boot項(xiàng)目的文章就介紹到這了,更多相關(guān)win10 linux啟動(dòng)spring-boot項(xiàng)目?jī)?nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Linux(Ubuntu 18.04)上安裝Anaconda步驟詳解
Anaconda是最受歡迎的python數(shù)據(jù)科學(xué)和機(jī)器學(xué)習(xí)平臺(tái),用于大規(guī)模數(shù)據(jù)處理,預(yù)測(cè)分析和科學(xué)計(jì)算。這篇文章主要介紹了Linux(Ubuntu 18.04)上安裝Anaconda的方法,需要的朋友可以參考下2018-11-11
jps查看進(jìn)程無(wú)法顯示的問(wèn)題及解決
文章描述了使用jps命令查看進(jìn)程無(wú)法顯示的問(wèn)題,并提供了解決方案,解決方法包括切換到tmp目錄,使用ll命令查看子目錄,找到并修改權(quán)限為755的"hsperfdata_[用戶(hù)名]"和"hsperfdata_root"目錄2025-01-01
在阿里云購(gòu)買(mǎi)云服務(wù)器并安裝寶塔面板的步驟
這篇文章主要介紹了在阿里云購(gòu)買(mǎi)云服務(wù)器并安裝寶塔面板的步驟,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-07-07
CentOS 5.4 服務(wù)器配置 yum安裝Apache+php+Mysql
Centos 里的 yum 在線(xiàn)安裝很慢.以下是替換為中國(guó)CentOS鏡像服務(wù)器!2010-03-03
windows apache 無(wú)法啟動(dòng)的兩種解決方法
apache無(wú)法啟動(dòng),查詢(xún)了一些方法,說(shuō)是更改端口,如果你還是無(wú)法啟動(dòng)。那就備份一下數(shù)據(jù)庫(kù),重裝apache吧2014-09-09
CentOS 7.2部署郵件服務(wù)器(Postfix)
這篇文章主要為大家詳細(xì)介紹了CentOS 7.2如何部署郵件服務(wù)器Postfix,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-11-11
linux線(xiàn)程間的同步與互斥知識(shí)點(diǎn)總結(jié)
在本篇文章里小編給大家整理的是關(guān)于linux線(xiàn)程間的同步與互斥的相關(guān)知識(shí)點(diǎn),有興趣的朋友們學(xué)習(xí)下。2019-11-11

