[特殊字符] 常用 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
相关推荐
她的男孩2 小时前
Spring Boot 接 Flowable 工作流:用 3 个注解搭一个请假审批流程
java·后端·架构
荣码4 小时前
LLM结构化输出:让AI返回JSON而不是废话,我踩了4个坑
java·python
plainGeekDev5 小时前
Gson → kotlinx.serialization
android·java·kotlin
小bo波14 小时前
Java Swing 图形用户界面实验 —— 从算术练习到游戏开发的完整实践
java·课程设计·gui·游戏开发·扫雷·swing
咖啡八杯15 小时前
GoF设计模式——备忘录模式
java·后端·spring·设计模式
SamDeepThinking1 天前
裁掉那个差程序员后,给你看团队里高手的代码:这个习惯,希望你有
java·后端·程序员
朕瞧着你甚好1 天前
技术雷达 & Java 集成评估报告 — Apache Tika 3.3.1
java·ai编程
MacroZheng1 天前
短短几天,暴涨2.8万Star!又一款编程神器开源!
java·人工智能·后端