0
点赞
收藏
分享

微信扫一扫

Maven 常用命令

MaxWen 2023-05-04 阅读 84


Maven 常用命令

 

 

创建web 项目

mvn archetype:generate -DgroupId=com.包名 -DartifactId=项目名 -DarchetypeArtifactId=maven-archetype-webapp -DinteractiveMode=false -DarchetypeCatalog=internal 

https://maven.apache.org/plugins-archives/maven-archetype-plugin-1.0-alpha-7/examples/webapp.html

 

 C:MVN>mvn archetype:generate

-DgroupId=com.包名

-DartifactId=项目名 

-DarchetypeArtifactId=maven-archetype-quickstart 

-DinteractiveMode=false -DarchetypeCatalog=internal 

 

mvn archetype:generate

mvn install

mvn clean

mvn clean compile

mvn clean test

mvn clean install

mvn clean package

mvn test

mvn package

mvn site

mvn deploy

 

查看某个build会激活的profile列表可以用:mvn help:active-profiles 

 

导出项目所依赖的jar

mvn dependency:copy-dependencies -DoutputDirectory=lib

 maven项目所依赖的jar包都会复制到项目目录下的lib目录下

设置依赖级别

 mvn dependency:copy-dependencies -DoutputDirectory=lib   -DincludeScope=compile

 

跳过测试

mvn install -Dmaven.test.skip=true

执行某一类测试 

mvn test -Dtest=*DaoTest

 

mvn dependency:resolve

mvn dependency:tree

mvn dependency:analyze

 

配置Maven Jetty插件

setting.xml

<pluginGroups>
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.
    <pluginGroup>com.your.plugins</pluginGroup>
    -->
     <pluginGroup>org.mortbay.jetty</pluginGroup>
  </pluginGroups>
 
或者在pom.xml文件中配置
<build>  
 <finalName>simple-webapp</finalName>  
 <plugins>  
  <plugin>  
   <groupId>org.mortbay.jetty</groupId>  
   <artifactId>maven-jetty-plugin</artifactId>        
  </plugin>  
 </plugins>  
 </build>  
启动Web项目(调用Jetty插件的run目标)
   mvn jetty:run
启动完后就可以通过(http://localhost:8080/simple-webapp/)访问。
 mvn jetty:run
http://127.0.0.1:8080/
mvn jetty:run -Djetty.port=9999
http://127.0.0.1:9999/
 mvn -Dslf4j=false -Dlog4j.configuration=file:./target/classes/log4j.properties jetty:run
 
mvn deploy
需要在POM.xml中配置
<distributionManagement>  
        <repository>  
            <id>releases</id>  
            <name>Local Nexus Repository</name>  
            <url>http://192.168.1.104:8081/nexus/content/repositories/releases/</url>  
        </repository>  
        <snapshotRepository>  
            <id>Snapshots</id>  
            <name>Local Nexus Repository</name>  
            <url>http://192.168.1.104:8081/nexus/content/repositories/snapshots</url>  
        </snapshotRepository>  
    </distributionManagement>  
</project>
在setting.xml中配置
<server>  
    <id>releases</id>  
<username>admin</username>  
<password>admin123</password>  
    </server>  
    <server>  
<id>Snapshots</id>  
<username>admin</username>  
<password>admin123</password>  
    </server>  
  </servers>

举报

相关推荐

0 条评论