[特殊字符] 常用 Maven 命令
1. 编译项目
bash
mvn compile
2. 运行 Spring Boot 应用
bash
mvn spring-boot:run
3. 打包项目
bash
mvn package
4. 清理并重新编译
bash
mvn clean compile
5. 运行测试
bash
mvn test
🚀 针对你的项目推荐命令
启动 Spring Boot 后端
bash
# 最常用的命令 - 启动开发服务器 mvn spring-boot:run
或者使用:
bash
# 先编译再运行 mvn compile mvn exec:java -Dexec.mainClass="com.example.Application"
📋 Maven 生命周期常用阶段
| 命令 | 作用 |
|---|---|
mvn clean | 清理 target 目录 |
mvn validate | 验证项目是否正确 |
mvn compile | 编译源代码 |
mvn test | 运行测试 |
mvn package | 打包成 JAR 文件 |
mvn install | 安装到本地仓库 |
mvn spring-boot:run | 运行 Spring Boot 应用 |
🔧 检查你的项目状态
1. 确认项目结构
bash
# 在项目根目录检查 ls -la # 应该看到 pom.xml 文件# 检查源代码是否存在 find src -name "*.java"
2. 检查 pom.xml
确保包含 Spring Boot 插件:
xml
<build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins> </build>
🎯 现在尝试这些命令
按顺序执行:
bash
# 1. 清理(可选) mvn clean# 2. 编译项目 mvn compile# 3. 启动应用(最重要) mvn spring-boot:run
💡 如果还是有问题
检查 Java 环境
bash
java -version mvn -version
使用 Maven Wrapper(如果有)
bash
# Windows mvnw.cmd spring-boot:run# Linux/Mac ./mvnw spring-boot:run
