Linux command
maven 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Compile project
mvn compile
Run tests
mvn test
Package (create JAR/WAR)
mvn package
Install to local repository
mvn install
Clean build artifacts
mvn clean
Skip tests during build
mvn package -DskipTests
Run specific goal
mvn dependency:tree
说明
Maven is a build automation and project management tool for Java. It manages dependencies, compiles code, runs tests, and packages applications based on the Project Object Model (pom.xml). Maven follows convention over configuration, using standard directory layouts and build lifecycles.
参数
- clean
- Remove build directory.
- compile
- Compile source code.
- test
- Run unit tests.
- package
- Create JAR/WAR.
- install
- Install to local repo.
- deploy
- Deploy to remote repo.
- -DskipTests
- Skip test execution.
- -U
- Force update snapshots.
- -o, --offline
- Offline mode.
- -P _profile_
- Activate profile.
FAQ
What is the maven command used for?
Maven is a build automation and project management tool for Java. It manages dependencies, compiles code, runs tests, and packages applications based on the Project Object Model (pom.xml). Maven follows convention over configuration, using standard directory layouts and build lifecycles.
How do I run a basic maven example?
Run `mvn compile` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does clean do in maven?
Remove build directory.