How to start the spring-boot project using the built-in linux system in win10

How to start the spring-boot project using the built-in linux system in win10

1. Install the built-in Linux subsystem of win10

1.1. Install the Linux subsystem

1.1.1. Upgrade or reinstall the Linux system

1. System requirements

You need to upgrade win10 to the 1st anniversary edition, or reinstall the system

2. Reinstall the system

The author tested and found that the Linux subsystem can be enabled after the following system is reinstalled

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. Enable Linux subsystem

Step 1. Enable developer mode

(Developer mode is no longer required after version 16215)

Settings --> Update & Security --> For developers

step2. Enable the Linux subsystem

Control Panel --> Programs and Features --> Turn Windows features on or off

1.1.3. Install Ubuntu system online

Open Microsoft Store and install Ubuntu system

1.1.4. Offline installation of Ubuntu system

Download the installation package and download the Linux system you want to install.

Reference link: https://docs.microsoft.com/en...

Download Ubuntu 16.04.

Invoke-WebRequest -Uri https://aka.ms/wsl-ubuntu-1604 -OutFile Ubuntu.appx -UseBasicParsing

You can also use curl to download, but you need to install curl first

curl.exe -L -o ubuntu-1604.appx https://aka.ms/wsl-ubuntu-1604

Install

Add-AppxPackage .\app_name.appx

1.1.5. Start Ubuntu system

Start Ubuntu system

After the installation is complete, open the search menu and enter the system name to search and start

Output the user and password that need to be set

Can you believe it? It's only 15.4MB

Installation Directory

C:\Users\Administrator\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc

home directory

C:\Users\Administrator\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu20.04onWindows_79rhkp1fndgsc\LocalState\rootfs\home

1.2. Enable ssh-server

1.2.1. Copy files to each other

The bash window of Ubuntu is different from that of xshell. You cannot paste by pressing shift+v, and the right button of the mouse cannot be used in the input interface. Here's how to paste the file:

Right click the title bar ==> Edit ==> Mark/Paste

This is still very troublesome. You can adjust the dialog box. There is a Properties dialog box property menu in the pop-up menu. Click it to enter the following figure

Check the quick edit and quick insert modes. These two modes support right-click selection and left-click paste operations.

Finally, the best way is to start the ssh service on Ubuntu and connect to it through xshell.

1.2.2. Modify apt source

Reference Links

https://developer.aliyun.com/...

Open with your favorite editor:

/etc/apt/sources.list

Replace the default archive.ubuntu.com with mirrors.aliyun.com

Modified content

Ubuntu 18.04

deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb 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 multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse

renew

apt-get update

1.2.3. Enable ssh

1. Install ssh

apt-get -y install openssh-server

2. Modify the configuration file, generally no modification is required

cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
vi /etc/ssh/sshd_config
# Modify the port number to avoid conflict with the Windows ssh service port Port 2222
#StrictModes yes #Comment #Login with password PasswordAuthentication yes 
# Allow root user login PermitRootLogin yes

3. Set the root account password

sudo -s
passwd root

4. Start ssh

service ssh start

5. If the prompt "sshd error: could not load host key" appears, regenerate it with the following command

rm /etc/ssh/ssh*key
dpkg-reconfigure openssh-server

Use xshell to connect to 127.0.0.1 and enter the account and password

1.2.4.Configure PS1 variables

What is the PS1 variable in Linux?

export PS1="\[\e[1;32;40m\][\u@\h \W]\\$ \[\e[m\]"

2. Build a development environment

2.1. Build a Java development environment

2.1.1. Install Java and 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/

Configuring environment variables

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

Configure Maven to use the Windows Maven local library directory. The corresponding directory of the Maven local library in Linux is /mnt/d/dev_mavenRepository/

The contents of settings.xml are as follows

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. Packaging and starting the spring-boot project

Go to the project directory and execute the following command to package the project

mvn clean package -DskipTests

Enter the target directory to start the project

cd target/
java -jar *.jar

It can be clearly seen that the Java program uses nearly 1G of memory

Summarize

This is the end of this article about how to use the built-in linux system of win10 to start the spring-boot project. For more relevant win10 linux start spring-boot project content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Script example for starting and stopping spring boot projects in Linux
  • How to start and stop SpringBoot jar program deployment shell script in Linux
  • Linux editing start, stop and restart springboot jar package script example
  • How to package and deploy springboot to linux server
  • How to run springboot in the background of linux
  • Methods and steps to deploy springboot project under Linux
  • How to deploy Spring boot to Linux

<<:  Several ways to use require/import keywords to import local images in v-for loop

>>:  mysql8.0.20 download and installation and problems encountered (illustration and text)

Recommend

React Fragment Introduction and Detailed Usage

Table of contents Preface Motivation for Fragment...

How to use Font Awesome 5 in Vue development projects

Table of contents Install Dependencies Configurat...

JavaScript method to detect the type of file

Table of contents 1. How to view the binary data ...

MySQL index for beginners

Preface Since the most important data structure i...

A brief discussion on value transfer between Vue components (including Vuex)

Table of contents From father to son: Son to Fath...

Use button trigger events to achieve background color flashing effect

To achieve the background color flashing effect, j...

Summary of common sql statements in Mysql

1. mysql export file: SELECT `pe2e_user_to_compan...

Detailed tutorial on installing nacos in docker and configuring the database

Environment Preparation Docker environment MySQL ...

How to choose the right MySQL datetime type to store your time

When building a database and writing a program, i...

Research on the problem of flip navigation with tilted mouse

In this article, we will analyze the production of...

How to use axios request in Vue project

Table of contents 1. Installation 2. There is no ...

HTML Basics: The basic structure of HTML

The basic structure of HTML hypertext documents is...

The most complete package.json analysis

Table of contents 1. Overview 2. Name field 3. Ve...