如何在 Amazon EC2 上部署 Java(Spring Boot 版)

news2025/4/22 19:29:43

让我们学习如何将 Java Spring Boot Web 服务器部署到 Amazon EC2。每月只需 3 美元。
使用 Azure,您可能不知道要花费多少钱。

Spring Boot 项目示例


在本教程中,我们将重点介绍如何将 Java Spring Boot 服务器部署到 Amazon EC2,因此我们不会学习如何从头开始构建 Spring Boot Web 服务。

启动 Amazon Linux EC2 实例


首先,编写下面的main.tf文件

provider "aws" {
  region = "ap-southeast-2"
}

resource "aws_instance" "example_server" {
  ami           = "ami-0f6a1a6507c55c9a8"
  instance_type = "t2.micro"
  key_name = "rockaws"

  tags = {
    Name = "RockSpringBootExample"
  }
}

 运行terraform apply 来创建EC2。

ninjamac@ip-192-168-1-2 target % terraform apply  

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_instance.example_server will be created
Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

aws_instance.example_server: Creating...
aws_instance.example_server: Still creating... [10s elapsed]
aws_instance.example_server: Creation complete after 16s [id=i-0d3b6e22f089bebf2]

通过 SSH 连接到 EC2 实例

ninjamac@ip-192-168-1-2 key % ssh -i rockaws.pem ec2-user@13.211.xx.xx

The authenticity of host '13.211.xx.xx (13.211.xx.xx)' can't be established.
ED25519 key fingerprint is SHA256:Q45g4PVqKnhtTnw9KQnWXnF5LoeOAFQ7qH2khVmw+Hg.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '13.211.xx.xx' (ED25519) to the list of known hosts.
   ,     #_
   ~\_  ####_        Amazon Linux 2023
  ~~  \_#####\
  ~~     \###|
  ~~       \#/ ___   https://aws.amazon.com/linux/amazon-linux-2023
   ~~       V~' '->
    ~~~         /
      ~~._.   _/
         _/ _/
       _/m/'

在 Amazon Linux 上安装 Java 17

[ec2-user@ip-172-31-14-36 ~]$ sudo yum install java-17-amazon-corretto-headless -y
Amazon Linux 2023 Kernel Livepatch repository   133 kB/s |  15 kB     00:00    
Dependencies resolved.
================================================================================
 Package                      Arch   Version                  Repository   Size
================================================================================
Installing:
 java-17-amazon-corretto-headless
                              x86_64 1:17.0.14+7-1.amzn2023.1 amazonlinux  91 M
Installing dependencies:
 alsa-lib                     x86_64 1.2.7.2-1.amzn2023.0.2   amazonlinux 504 k
 cairo                        x86_64 1.18.0-4.amzn2023.0.1    amazonlinux 718 k
 dejavu-sans-fonts            noarch 2.37-16.amzn2023.0.2     amazonlinux 1.3 M
 dejavu-sans-mono-fonts       noarch 2.37-16.amzn2023.0.2     amazonlinux 467 k
 dejavu-serif-fonts           noarch 2.37-16.amzn2023.0.2     amazonlinux 1.0 M
 fontconfig                   x86_64 2.13.94-2.amzn2023.0.2   amazonlinux 273 k
 fonts-filesystem             noarch 1:2.0.5-12.amzn2023.0.2  amazonlinux 9.5 k
 freetype                     x86_64 2.13.2-5.amzn2023.0.1    amazonlinux 423 k
 google-noto-fonts-common     noarch 20201206-2.amzn2023.0.2  amazonlinux  15 k
 google-noto-sans-vf-fonts    noarch 20201206-2.amzn2023.0.2  amazonlinux 492 k
 graphite2                    x86_64 1.3.14-7.amzn2023.0.2    amazonlinux  97 k
 harfbuzz                     x86_64 7.0.0-2.amzn2023.0.2     amazonlinux 873 k
 javapackages-filesystem      noarch 6.0.0-7.amzn2023.0.6     amazonlinux  12 k
 langpacks-core-font-en       noarch 3.0-21.amzn2023.0.4      amazonlinux  10 k
 libX11                       x86_64 1.8.10-2.amzn2023.0.1    amazonlinux 659 k
 libX11-common                noarch 1.8.10-2.amzn2023.0.1    amazonlinux 147 k
 libXau                       x86_64 1.0.11-6.amzn2023.0.1    amazonlinux  33 k
 libXext                      x86_64 1.3.6-1.amzn2023.0.1     amazonlinux  42 k
 libXrender                   x86_64 0.9.11-6.amzn2023.0.1    amazonlinux  29 k
 libbrotli                    x86_64 1.0.9-4.amzn2023.0.2     amazonlinux 315 k
 libjpeg-turbo                x86_64 2.1.4-2.amzn2023.0.5     amazonlinux 190 k
 libpng                       x86_64 2:1.6.37-10.amzn2023.0.6 amazonlinux 128 k
 libxcb                       x86_64 1.17.0-1.amzn2023.0.1    amazonlinux 235 k
 pixman                       x86_64 0.43.4-1.amzn2023.0.4    amazonlinux 296 k
 xml-common                   noarch 0.6.3-56.amzn2023.0.2    amazonlinux  32 k

Transaction Summary
================================================================================
Install  26 Packages

Total download size: 99 M
Installed size: 260 M
Downloading Packages:
(1/26): alsa-lib-1.2.7.2-1.amzn2023.0.2.x86_64. 6.8 MB/s | 504 kB     00:00    
(2/26): cairo-1.18.0-4.amzn2023.0.1.x86_64.rpm  8.4 MB/s | 718 kB     00:00    
(3/26): dejavu-sans-fonts-2.37-16.amzn2023.0.2.  13 MB/s | 1.3 MB     00:00    
(4/26): dejavu-sans-mono-fonts-2.37-16.amzn2023  11 MB/s | 467 kB     00:00    
(5/26): dejavu-serif-fonts-2.37-16.amzn2023.0.2  26 MB/s | 1.0 MB     00:00    
(6/26): fontconfig-2.13.94-2.amzn2023.0.2.x86_6 5.4 MB/s | 273 kB     00:00    
(7/26): fonts-filesystem-2.0.5-12.amzn2023.0.2. 245 kB/s | 9.5 kB     00:00    
(8/26): freetype-2.13.2-5.amzn2023.0.1.x86_64.r  11 MB/s | 423 kB     00:00    
(9/26): google-noto-sans-vf-fonts-20201206-2.am  20 MB/s | 492 kB     00:00    
(10/26): google-noto-fonts-common-20201206-2.am 542 kB/s |  15 kB     00:00    
(11/26): graphite2-1.3.14-7.amzn2023.0.2.x86_64 2.1 MB/s |  97 kB     00:00    
(12/26): harfbuzz-7.0.0-2.amzn2023.0.2.x86_64.r  14 MB/s | 873 kB     00:00    
(13/26): javapackages-filesystem-6.0.0-7.amzn20 336 kB/s |  12 kB     00:00    
(14/26): langpacks-core-font-en-3.0-21.amzn2023 440 kB/s |  10 kB     00:00    
(15/26): libX11-1.8.10-2.amzn2023.0.1.x86_64.rp  16 MB/s | 659 kB     00:00    
(16/26): libX11-common-1.8.10-2.amzn2023.0.1.no 4.8 MB/s | 147 kB     00:00    
(17/26): libXau-1.0.11-6.amzn2023.0.1.x86_64.rp 1.4 MB/s |  33 kB     00:00    
(18/26): libXext-1.3.6-1.amzn2023.0.1.x86_64.rp 1.8 MB/s |  42 kB     00:00    
(19/26): libXrender-0.9.11-6.amzn2023.0.1.x86_6 1.3 MB/s |  29 kB     00:00    
(20/26): libbrotli-1.0.9-4.amzn2023.0.2.x86_64.  10 MB/s | 315 kB     00:00    
(21/26): libjpeg-turbo-2.1.4-2.amzn2023.0.5.x86 6.2 MB/s | 190 kB     00:00    
(22/26): libpng-1.6.37-10.amzn2023.0.6.x86_64.r 4.6 MB/s | 128 kB     00:00    
(23/26): libxcb-1.17.0-1.amzn2023.0.1.x86_64.rp  10 MB/s | 235 kB     00:00    
(24/26): xml-common-0.6.3-56.amzn2023.0.2.noarc 1.6 MB/s |  32 kB     00:00    
(25/26): pixman-0.43.4-1.amzn2023.0.4.x86_64.rp 7.5 MB/s | 296 kB     00:00    
(26/26): java-17-amazon-corretto-headless-17.0.  66 MB/s |  91 MB     00:01    
--------------------------------------------------------------------------------
Total                                            62 MB/s |  99 MB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                        1/1 
  Installing       : fonts-filesystem-1:2.0.5-12.amzn2023.0.2.noarch       1/26 
  Installing       : dejavu-sans-mono-fonts-2.37-16.amzn2023.0.2.noarch    2/26 
  Installing       : dejavu-sans-fonts-2.37-16.amzn2023.0.2.noarch         3/26 
  Installing       : libpng-2:1.6.37-10.amzn2023.0.6.x86_64                4/26 
  Installing       : dejavu-serif-fonts-2.37-16.amzn2023.0.2.noarch        5/26 
  Running scriptlet: xml-common-0.6.3-56.amzn2023.0.2.noarch               6/26 
  Installing       : xml-common-0.6.3-56.amzn2023.0.2.noarch               6/26 
  Installing       : pixman-0.43.4-1.amzn2023.0.4.x86_64                   7/26 
  Installing       : libjpeg-turbo-2.1.4-2.amzn2023.0.5.x86_64             8/26 
  Installing       : libbrotli-1.0.9-4.amzn2023.0.2.x86_64                 9/26 
  Installing       : libXau-1.0.11-6.amzn2023.0.1.x86_64                  10/26 
  Installing       : libxcb-1.17.0-1.amzn2023.0.1.x86_64                  11/26 
  Installing       : libX11-common-1.8.10-2.amzn2023.0.1.noarch           12/26 
  Installing       : libX11-1.8.10-2.amzn2023.0.1.x86_64                  13/26 
  Installing       : libXext-1.3.6-1.amzn2023.0.1.x86_64                  14/26 
  Installing       : libXrender-0.9.11-6.amzn2023.0.1.x86_64              15/26 
  Installing       : javapackages-filesystem-6.0.0-7.amzn2023.0.6.noarc   16/26 
  Installing       : graphite2-1.3.14-7.amzn2023.0.2.x86_64               17/26 
  Installing       : google-noto-fonts-common-20201206-2.amzn2023.0.2.n   18/26 
  Installing       : google-noto-sans-vf-fonts-20201206-2.amzn2023.0.2.   19/26 
  Installing       : langpacks-core-font-en-3.0-21.amzn2023.0.4.noarch    20/26 
  Installing       : cairo-1.18.0-4.amzn2023.0.1.x86_64                   21/26 
  Installing       : harfbuzz-7.0.0-2.amzn2023.0.2.x86_64                 22/26 
  Installing       : freetype-2.13.2-5.amzn2023.0.1.x86_64                23/26 
  Installing       : fontconfig-2.13.94-2.amzn2023.0.2.x86_64             24/26 
  Running scriptlet: fontconfig-2.13.94-2.amzn2023.0.2.x86_64             24/26 
  Installing       : alsa-lib-1.2.7.2-1.amzn2023.0.2.x86_64               25/26 
  Installing       : java-17-amazon-corretto-headless-1:17.0.14+7-1.amz   26/26 
  Running scriptlet: java-17-amazon-corretto-headless-1:17.0.14+7-1.amz   26/26 
  Running scriptlet: fontconfig-2.13.94-2.amzn2023.0.2.x86_64             26/26 
  Running scriptlet: java-17-amazon-corretto-headless-1:17.0.14+7-1.amz   26/26 
  Verifying        : alsa-lib-1.2.7.2-1.amzn2023.0.2.x86_64                1/26 
  Verifying        : cairo-1.18.0-4.amzn2023.0.1.x86_64                    2/26 
  Verifying        : dejavu-sans-fonts-2.37-16.amzn2023.0.2.noarch         3/26 
  Verifying        : dejavu-sans-mono-fonts-2.37-16.amzn2023.0.2.noarch    4/26 
  Verifying        : dejavu-serif-fonts-2.37-16.amzn2023.0.2.noarch        5/26 
  Verifying        : fontconfig-2.13.94-2.amzn2023.0.2.x86_64              6/26 
  Verifying        : fonts-filesystem-1:2.0.5-12.amzn2023.0.2.noarch       7/26 
  Verifying        : freetype-2.13.2-5.amzn2023.0.1.x86_64                 8/26 
  Verifying        : google-noto-fonts-common-20201206-2.amzn2023.0.2.n    9/26 
  Verifying        : google-noto-sans-vf-fonts-20201206-2.amzn2023.0.2.   10/26 
  Verifying        : graphite2-1.3.14-7.amzn2023.0.2.x86_64               11/26 
  Verifying        : harfbuzz-7.0.0-2.amzn2023.0.2.x86_64                 12/26 
  Verifying        : java-17-amazon-corretto-headless-1:17.0.14+7-1.amz   13/26 
  Verifying        : javapackages-filesystem-6.0.0-7.amzn2023.0.6.noarc   14/26 
  Verifying        : langpacks-core-font-en-3.0-21.amzn2023.0.4.noarch    15/26 
  Verifying        : libX11-1.8.10-2.amzn2023.0.1.x86_64                  16/26 
  Verifying        : libX11-common-1.8.10-2.amzn2023.0.1.noarch           17/26 
  Verifying        : libXau-1.0.11-6.amzn2023.0.1.x86_64                  18/26 
  Verifying        : libXext-1.3.6-1.amzn2023.0.1.x86_64                  19/26 
  Verifying        : libXrender-0.9.11-6.amzn2023.0.1.x86_64              20/26 
  Verifying        : libbrotli-1.0.9-4.amzn2023.0.2.x86_64                21/26 
  Verifying        : libjpeg-turbo-2.1.4-2.amzn2023.0.5.x86_64            22/26 
  Verifying        : libpng-2:1.6.37-10.amzn2023.0.6.x86_64               23/26 
  Verifying        : libxcb-1.17.0-1.amzn2023.0.1.x86_64                  24/26 
  Verifying        : pixman-0.43.4-1.amzn2023.0.4.x86_64                  25/26 
  Verifying        : xml-common-0.6.3-56.amzn2023.0.2.noarch              26/26 

Installed:
  alsa-lib-1.2.7.2-1.amzn2023.0.2.x86_64                                        
  cairo-1.18.0-4.amzn2023.0.1.x86_64                                            
  dejavu-sans-fonts-2.37-16.amzn2023.0.2.noarch                                 
  dejavu-sans-mono-fonts-2.37-16.amzn2023.0.2.noarch                            
  dejavu-serif-fonts-2.37-16.amzn2023.0.2.noarch                                
  fontconfig-2.13.94-2.amzn2023.0.2.x86_64                                      
  fonts-filesystem-1:2.0.5-12.amzn2023.0.2.noarch                               
  freetype-2.13.2-5.amzn2023.0.1.x86_64                                         
  google-noto-fonts-common-20201206-2.amzn2023.0.2.noarch                       
  google-noto-sans-vf-fonts-20201206-2.amzn2023.0.2.noarch                      
  graphite2-1.3.14-7.amzn2023.0.2.x86_64                                        
  harfbuzz-7.0.0-2.amzn2023.0.2.x86_64                                          
  java-17-amazon-corretto-headless-1:17.0.14+7-1.amzn2023.1.x86_64              
  javapackages-filesystem-6.0.0-7.amzn2023.0.6.noarch                           
  langpacks-core-font-en-3.0-21.amzn2023.0.4.noarch                             
  libX11-1.8.10-2.amzn2023.0.1.x86_64                                           
  libX11-common-1.8.10-2.amzn2023.0.1.noarch                                    
  libXau-1.0.11-6.amzn2023.0.1.x86_64                                           
  libXext-1.3.6-1.amzn2023.0.1.x86_64                                           
  libXrender-0.9.11-6.amzn2023.0.1.x86_64                                       
  libbrotli-1.0.9-4.amzn2023.0.2.x86_64                                         
  libjpeg-turbo-2.1.4-2.amzn2023.0.5.x86_64                                     
  libpng-2:1.6.37-10.amzn2023.0.6.x86_64                                        
  libxcb-1.17.0-1.amzn2023.0.1.x86_64                                           
  pixman-0.43.4-1.amzn2023.0.4.x86_64                                           
  xml-common-0.6.3-56.amzn2023.0.2.noarch                                       

Complete!

使用 mvn 创建 jar 文件


只需运行 mvn package 命令即可创建 Java 应用程序的 .jar 文件。
您将在目标目录中看到两个 .jar 文件:

ninjamac@ip-192-168-1-2 target % ls -al
total 44624
drwxr-xr-x  16 ninjamac  staff       512  4 20 20:20 .
drwxr-xr-x  11 ninjamac  staff       352  4 20 19:38 ..
drwxr-xr-x   4 ninjamac  staff       128  4 20 19:38 classes
drwxr-xr-x   3 ninjamac  staff        96  4 20 19:38 generated-sources
drwxr-xr-x   3 ninjamac  staff        96  4 20 19:38 generated-test-sources
-rw-r--r--   1 ninjamac  staff  22820488  4 20 19:40 hello-0.0.1-SNAPSHOT.jar
-rw-r--r--   1 ninjamac  staff      3404  4 20 19:39 hello-0.0.1-SNAPSHOT.jar.original

使用 rsync 将 .jar 文件复制到 EC2

ninjamac@ip-192-168-1-2 target % rsync -avz -e "ssh -i ~/Desktop/Rock/key/rockaws.pem" ./hello-0.0.1-SNAPSHOT.jar ec2-user@13.211.xx.xx:~/
building file list ... done
hello-0.0.1-SNAPSHOT.jar
sent 20421458 bytes  received 42 bytes  220772.97 bytes/sec

 使用 Java 执行 .jar 文件


我们之前安装了 Java,因此可以使用它的命令行界面 (CLI) 运行 .jar 文件,使用 -jar 参数并传入 .jar 文件的路径:

[ec2-user@ip-172-31-14-36 ~]$ java -jar ./hello-0.0.1-SNAPSHOT.jar 
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::                (v3.3.0)

2025-04-20T12:41:34.568Z  INFO 26691 --- [hello] [           main] com.learnaws.hello.HelloApplication      : Starting HelloApplication v0.0.1-SNAPSHOT using Java 17.0.14 with PID 26691 (/home/ec2-user/hello-0.0.1-SNAPSHOT.jar started by ec2-user in /home/ec2-user)
2025-04-20T12:41:34.583Z  INFO 26691 --- [hello] [           main] com.learnaws.hello.HelloApplication      : No active profile set, falling back to 1 default profile: "default"
2025-04-20T12:41:37.221Z  INFO 26691 --- [hello] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port 8080 (http)
2025-04-20T12:41:37.244Z  INFO 26691 --- [hello] [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2025-04-20T12:41:37.244Z  INFO 26691 --- [hello] [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.24]
2025-04-20T12:41:37.555Z  INFO 26691 --- [hello] [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2025-04-20T12:41:37.556Z  INFO 26691 --- [hello] [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 2851 ms
2025-04-20T12:41:39.058Z  INFO 26691 --- [hello] [           main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 1 endpoint beneath base path '/actuator'
2025-04-20T12:41:39.222Z  INFO 26691 --- [hello] [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port 8080 (http) with context path '/'
2025-04-20T12:41:39.254Z  INFO 26691 --- [hello] [           main] com.learnaws.hello.HelloApplication      : Started HelloApplication in 5.58 seconds (process running for 6.56)

在 EC2 安全组中为 Spring Boot 启用 8080 端口


前往连接到您的 EC2 实例的安全组,并添加 8080 端口范围:

 使用 IP 测试在 EC2 上运行的 Spring Boot 服务器

使用curl测试 actuator的健康状态

ninjamac@ip-192-168-1-2 target % curl 13.211.239.xx:8080/actuator/health
{"status":"UP"}%

如何为生产环境设置 Spring Boot

  1. 使用 Caddy 设置自定义域名和 SSL
  2. 将您的域名指向 EC2 IP
  3. 安装并设置 Caddy 作为反向代理
  4. 设置 CDN(例如 CloudFront 或 Cloudflare)用于缓存

保持 Java 服务器在后台运行


我们希望在系统重启和应用程序崩溃时自动启动应用程序,为此可以使用 systemd。

创建 systemd 服务文件
使用 vim 在 /etc/systemd/system/java-server.service 中创建一个服务文件:

sudo vim /etc/systemd/system/java-server.service
 

[Unit]
Description=Spring Boot Server

[Service]
ExecStart=java -jar /home/ec2-user/hello-0.0.1-SNAPSHOT.jar
Restart=on-failure
RestartSec=1s

[Install]
WantedBy=multi-user.target

使用 systemctl 启用 java-server 服务
现在您需要重新加载 systemd 并启用 java 服务器:

sudo systemctl daemon-reload
sudo systemctl enable java-server
启动 java-server 服务
sudo systemctl start java-server
使用 systemctl 检查状态
sudo systemctl status java-server
您将看到类似以下内容:

[ec2-user@ip-172-31-14-36 ~]$ sudo systemctl daemon-reload 
[ec2-user@ip-172-31-14-36 ~]$ sudo systemctl enable java-server
Created symlink /etc/systemd/system/multi-user.target.wants/java-server.service → /etc/systemd/system/java-server.service.
[ec2-user@ip-172-31-14-36 ~]$ sudo systemctl start java-server
[ec2-user@ip-172-31-14-36 ~]$ sudo systemctl status java-server
● java-server.service - Spring Boot Server
     Loaded: loaded (/etc/systemd/system/java-server.service; enabled; preset: >
     Active: active (running) since Sun 2025-04-20 12:57:18 UTC; 1s ago
   Main PID: 27376 (java)
      Tasks: 15 (limit: 1111)
     Memory: 46.4M
        CPU: 1.405s
     CGroup: /system.slice/java-server.service
             └─27376 java -jar /home/ec2-user/hello-0.0.1-SNAPSHOT.jar

Apr 20 12:57:18 ip-172-31-14-36.ap-southeast-2.compute.internal systemd[1]: Sto>
Apr 20 12:57:18 ip-172-31-14-36.ap-southeast-2.compute.internal systemd[1]: jav>
Apr 20 12:57:18 ip-172-31-14-36.ap-southeast-2.compute.internal systemd[1]: Sta>

现在,即使您重启系统或退出 SSH 会话,这也能确保您的 Java Web 服务器继续运行。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2340304.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

IDEA打不开、打开报错

目录 场景异常原因解决 场景 1、本机已经安装了IDEA 2、再次安装另外一个版本的IDEA后打不开、打开报错 异常 这里忘记截图了。。。 原因 情况1-打不开:在同一台电脑安装多个IDEA是需要对idea的配置文件进行调整的,否则打不开 情况2-打开报错&#…

【React】项目的搭建

create-react-app 搭建vite 搭建相关下载 在Vue中搭建项目的步骤:1.首先安装脚手架的环境,2.通过脚手架的指令创建项目 在React中有两种方式去搭建项目:1.和Vue一样,先安装脚手架然后通过脚手架指令搭建;2.npx create-…

CSS例子 > 图片瀑布流布局(vue2)

<template><div class"container"><!-- 临时容器用于计算高度 --><div v-if"!isLayoutReady" class"temp-container"><divv-for"(item, index) in list":key"temp- index":ref"(el) > …

1.2软考系统架构设计师:系统架构的定义与作用 - 练习题附答案及超详细解析

系统架构定义与作用综合知识单选题 题目覆盖核心概念、发展历程、设计原则、评估标准及易混淆点&#xff0c;附答案解析&#xff1a; 1. 系统架构的标准定义源自于以下哪个标准&#xff1f; A. ISO/IEC 9126 B. IEEE 1471-2000 C. TOGAF 9.2 D. ITIL v4 答案&#xff1a;B 简…

关于springmvc的404问题的一种猜测解决方案

本文是记录关于在学习动力结点老杜的springmvc时候遇到的404报错的一种解决方式&#xff1b; 由于本人之前学过老杜的springmvc&#xff0c;且运行成功&#xff0c;当时使用的是tomcat10.1.19版本。 idea使用2023.3.2版本。 而这次进行回顾的时候&#xff0c;使用tomcat10.0.1…

使用Postman调测“获取IAM用户Token”接口实际操作

概述 Postman是网页调试与辅助接口调用的工具&#xff0c;具有界面简洁清晰、操作方便快捷的特性&#xff0c;可以处理用户发送的HTTP请求&#xff0c;例如&#xff1a;GET&#xff0c;PUT、POST&#xff0c;DELETE等&#xff0c;支持用户修改HTTP请求中的参数并返回响应数据。…

如何测试雷达与相机是否时间同步?

在多传感器融合系统中&#xff0c;相机与雷达的协同感知已成为环境理解的关键。相机通过捕捉纹理信息识别物体类别&#xff0c;而雷达利用激光或毫米波实现全天候精确测距。两者的数据融合既能避免单一传感器缺陷&#xff08;如相机受光照影响、雷达缺乏语义信息&#xff09;&a…

爆肝整理!Stable Diffusion的完全使用手册(二)

继续介绍Stable Diffusion的文生图界面功能。 往期文章详见: 爆肝整理&#xff01;Stable Diffusion的完全使用手册&#xff08;一&#xff09; 下面接着对SD的文生图界面的进行详细的介绍。本期介绍文生图界面的截图2&#xff0c;主要包含生成模块下的采用方法、调度类型、迭…

OpenCV day5

函数内容接上文&#xff1a;OpenCV day4-CSDN博客 目录 9.cv2.adaptiveThreshold(): 10.cv2.split()&#xff1a; 11.cv2.merge()&#xff1a; 12.cv2.add()&#xff1a; 13.cv2.subtract()&#xff1a; 14.cv2.multiply()&#xff1a; 15.cv2.divide()&#xff1a; 1…

基于Spring Boot+微信小程序的智慧农蔬微团购平台-项目分享

基于Spring Boot微信小程序的智慧农蔬微团购平台-项目分享 项目介绍项目摘要目录系统功能图管理员E-R图用户E-R图项目预览登录页面商品管理统计分析用户地址添加 最后 项目介绍 使用者&#xff1a;管理员、用户 开发技术&#xff1a;MySQLSpringBoot微信小程序 项目摘要 随着…

WPF的发展历程

文章目录 WPF的发展历程引言起源与背景&#xff08;2001-2006&#xff09;从Avalon到WPF设计目标与创新理念 WPF核心技术特点与架构基础架构与渲染模型关键技术特点MVVM架构模式 WPF在现代Windows开发中的地位与前景当前市场定位与其他微软UI技术的关系未来发展前景 社区贡献与…

Franka机器人ROS 2来袭:解锁机器人多元应用新可能

前言&#xff1a; 在机器人技术蓬勃发展的当下&#xff0c;每一次创新都可能为行业带来新的变革。2025年3月12日&#xff0c;Franka Robotics发布的Franka ROS 2软件包首次版本0.1.0&#xff0c;将著名的franka_ros软件包引入当前的ROS 2 LTS Humble Hawksbill&#xff0c;这一…

树莓派5+Vosk+python实现语音识别

简介 Vosk是语音识别开源框架&#xff0c;支持二十种语言 - 中文&#xff0c;英语&#xff0c;印度英语&#xff0c;德语&#xff0c;法语&#xff0c;西班牙语&#xff0c;葡萄牙语&#xff0c;俄语&#xff0c;土耳其语&#xff0c;越南语&#xff0c;意大利语&#xff0c;荷…

数据结构——顺序表(C语言实现)

1.顺序表的概述 1.1 顺序表的概念及结构 在了解顺序表之前&#xff0c;我们要先知道线性表的概念&#xff0c;线性表&#xff0c;顾名思义&#xff0c;就是一个线性的且具有n个相同类型的数据元素的有限序列&#xff0c;常见的线性表有顺序表、链表、栈、队列、字符串等等。线…

STP原理与配置以及广播风暴实验STP实验

学习目标 环路引起的问题 掌握STP的工作原理 掌握STP的基本配置 STP的配置 环路引起的问题 一、广播风暴&#xff08;Broadcast Storm&#xff09; 问题原理&#xff1a; 交换机对广播帧&#xff08;如 ARP 请求、DHCP 发现报文&#xff09;的处理方式是洪泛&#xff0…

网络不可达network unreachable问题解决过程

问题&#xff1a;访问一个环境中的路由器172.16.1.1&#xff0c;发现ssh无法访问&#xff0c;ping发现回网络不可达 C:\Windows\System32>ping 172.16.1.1 正在 Ping 172.16.1.1 具有 32 字节的数据: 来自 172.16.81.1 的回复: 无法访问目标网。 来自 172.16.81.1 的回复:…

力扣经典拓扑排序

207. 课程表&#xff08;Course Schedule&#xff09; 你这个学期必须选修 numCourses 门课程&#xff0c;记为 0 到 numCourses - 1 。 在选修某些课程之前需要一些先修课程。先修课程按数组 prerequisites 给出&#xff0c;其中 prerequisites[i] [ai, bi] &#xff0c;表…

【第16届蓝桥杯C++C组】--- 2025

hello呀&#xff0c;小伙伴们&#xff0c;这是第16届蓝桥杯第二道填空题&#xff0c;和第一道填空题一样也是十分基础的题目&#xff0c;有C语言基础基本都可以解&#xff0c;下面我讲讲我当时自己的思路和想法&#xff0c;如果你们有更优化的代码和思路&#xff0c;也可以分享…

前端基础之《Vue(7)—生命周期》

一、什么是生命周期 1、生命周期 组件从“生”到“死”的全过程。 每一个组件都有生命周期。 2、生命周期四大阶段 创建阶段&#xff1a;beforeCreate、created 挂载阶段&#xff1a;beforeMount、mounted 更新阶段&#xff1a;beforeUpdate、updated 销毁阶段&#xff1a;be…

C语言高频面试题——指针数组和数组指针

指针数组和数组指针是 C/C 中容易混淆的两个概念&#xff0c;以下是详细对比&#xff1a; 1. 指针数组&#xff08;Array of Pointers&#xff09; 定义&#xff1a;一个数组&#xff0c;其元素是 指针类型。语法&#xff1a;type* arr[元素个数]; 例如&#xff1a;int* ptr_a…