maven , mvn 运行 项目

提示:环境搭建


前言

提示:版本

spirngboot 3.2
jdk 21
mvn 3.9


提示:以下是本篇文章正文内容,下面案例可供参考

一、使用步骤

1. 以构建含有 pom.xml 的项目

threading-comparison/
├── pom.xml                          # Parent POM with Spring Boot 3.2 and JDK 21
├── traditional-threading/           # Traditional multithreading module
│   ├── pom.xml
│   └── src/main/java/com/example/traditional/
│       ├── TraditionalThreadingApplication.java
│       ├── service/TraditionalTaskService.java
│       └── controller/TraditionalController.java
├── virtual-threading/               # Virtual threading module
│   ├── pom.xml
│   └── src/main/java/com/example/virtual/
│       ├── VirtualThreadingApplication.java
│       ├── service/VirtualTaskService.java
│       └── controller/VirtualController.java
├── load-test.sh                     # Linux/Mac load testing script
├── load-test.bat                    # Windows load testing script
├── qps_test.py                      # Python-based QPS testing script
└── README.md                        # This file

2.mvn 运行具体项目

cd traditional-threading
mvn spring-boot:run
traditional-threading>mvn spring-boot:run
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< com.example:traditional-threading >------------------
[INFO] Building Traditional Threading Module 1.0.0
[INFO]   from pom.xml
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] >>> spring-boot:3.2.0:run (default-cli) > test-compile @ traditional-threading >>>
[INFO]
[INFO] --- resources:3.3.1:resources (default-resources) @ traditional-threading ---
[INFO] Copying 1 resource from src\main\resources to target\classes
[INFO]
[INFO] --- compiler:3.11.0:compile (default-compile) @ traditional-threading ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- resources:3.3.1:testResources (default-testResources) @ traditional-threading ---
[INFO] skip non existing resourceDirectory D:\devTemp\jdk21test\traditional-threading\src\test\resources
[INFO]
[INFO] --- compiler:3.11.0:testCompile (default-testCompile) @ traditional-threading ---
[INFO] No sources to compile
[INFO]
[INFO] <<< spring-boot:3.2.0:run (default-cli) < test-compile @ traditional-threading <<<
[INFO]
[INFO]
[INFO] --- spring-boot:3.2.0:run (default-cli) @ traditional-threading ---
[INFO] Attaching agents: []

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.2.0)

2025-09-10 09:58:56 - Starting TraditionalThreadingApplication using Java 21.0.7 with PID 8916 (D:\devTemp\jdk21test\traditional-threading\target\classes started by jeremy in D:\devTemp\jdk21test\traditional-threading) [main]
2025-09-10 09:58:56 - No active profile set, falling back to 1 default profile: "default" [main]
2025-09-10 09:58:56 - Tomcat initialized with port 8080 (http) [main]
2025-09-10 09:58:56 - Starting service [Tomcat] [main]
2025-09-10 09:58:56 - Starting Servlet engine: [Apache Tomcat/10.1.16] [main]
2025-09-10 09:58:56 - Initializing Spring embedded WebApplicationContext [main]
2025-09-10 09:58:56 - Root WebApplicationContext: initialization completed in 653 ms [main]
2025-09-10 09:58:57 - Exposing 4 endpoint(s) beneath base path '/actuator' [main]
2025-09-10 09:58:57 - Tomcat started on port 8080 (http) with context path '' [main]
2025-09-10 09:58:57 - Started TraditionalThreadingApplication in 1.263 seconds (process running for 1.473) [main]

3.mvn 指定模块>运行具体项目

进入 Parent POM 文件目录,根目录

mvn -pl virtual-threading spring-boot:run
  • -pl virtual-threading:指定要构建/运行的 Maven 模块,这里是 virtual-threading 模块
  • spring-boot:run:是 Spring Boot Maven 插件的目标,用于启动 Spring Boot 应用程序
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值