clean :清除由项目编译创建的target,
install:安装jar包到本地仓库。
首先是clean 的举例,
因为上一个项目刚编译完毕,所以我们有一个这样的目录

接着,在cmd中输入:mvn clean。

可以看到,效果就是删掉target目标文件夹。
下面对install进行举例,通过一个对比。
首先是参考之前的项目创建过程,创建另一个项目maven02
speak.java
package com.imooc.maven01.util;
import com.imooc.maven01.model.helloworld;
public class speak{
public string sayhi(){
return new helloworld().sayhello();
}
}speaktest.java
package com.imooc.maven01.util;
import org.junit.*;
import org.junit.assert.*;
public class speaktest{
@test
public void testhi(){
assert.assertequals("hello world!", new speak().sayhi());
}
}pom.xml
<?xml version="1.0" encoding="utf-8"?>
<project xmlns="http://maven.apache.org/pom/4.0.0"
xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"
xsi:schemalocation="http://maven.apache.org/pom/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
<modelversion>4.0.0</modelversion>
<groupid>com.imooc.maven02</groupid>
<artifactid>maven02-model02</artifactid>
<version>0.0.1snapshot</version>
<properties>
<project.build.sourceencoding>utf-8</project.build.sourceencoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupid>junit</groupid>
<artifactid>junit</artifactid>
<version>4.10</version>
</dependency>
<dependency>
<groupid>com.imooc.maven01</groupid>
<artifactid>maven01-model</artifactid>
<version>0.0.1snapshot</version>
</dependency>
</dependencies>
</project>xml文件中添加了对maven01的依赖,因为speak中导入了maven01的项目包。
运行:mvn compile

显示maven01的包不存在,我们在maven01项目中用“ mvn install ” 命令将该项目添加到我们的本地仓库,再重新回到maven02编译:

项目就成功了!
到此这篇关于maven中两个命令clean 和 install的使用的文章就介绍到这了,更多相关maven clean 和 install内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!
发表评论