maven常用命令

1.   编译项目并发布到本地仓库

mvn clean install

2. 项目发布到私服

mvn clean deploy

3.  将项目依赖项拷贝到目录target/lib

mvn dependency:copy-dependencies -DoutputDirectory=target/lib

4. 将jar包放在本地仓库

mvn install:install-file -DgroupId=customjar.importdirectly -DartifactId=ojdbc -Dversion=15.0 -Dpackaging=jar -Dfile=E:\ojdbc-15.0.jar

pom.xml中引用如下:

		<dependency>
			<groupId>customjar.importdirectly</groupId>
			<artifactId>ojdbc</artifactId>
			<version>15.0</version>
		</dependency>

5.将项目发布到私服

	<distributionManagement>
		<repository>
			<id>jzy3d-ftp</id>
			<name>Jzy3d Maven Folder</name>
			<url>ftp://ftp.cluster013.ovh.net/maven/releases</url>
		</repository>
		<snapshotRepository>
			<id>jzy3d-ftp</id>
			<name>Jzy3d Maven Folder SNAPSHOTS</name>
			<url>ftp://ftp.cluster013.ovh.net/maven/snapshots</url>
		</snapshotRepository>
	</distributionManagement>

首先指定私服release和snapshot的Reposity中的id、name、url,这些可以直接在$M2_HOME\conf\settings.xml中找到,如果你使用的私服的话。

其次$M2_HOME\conf\settings.xml文件中Servers下需要配置相关登陆信息

    <server>
      <id>xxx-release</id>
      <username>deployment</username>
      <password>deployment123</password>
    </server>
具体细节隐去。

6. 将jar包发布到私服(非本地仓库)

mvn deploy:deploy-file -DgroupId=customjar.importdirectly –DartifactId=commons-math3 
   -Dversion=3.2.lastUpdated -Dfile=D:\log\customjar\importdirectly\commons-math3\3.2\commons-math3-3.2.jar.lastUpdated 
   -DrepositoryId=xx-release -Durl=http://ip:port/nexus/content/repositories/xx-release
凡是涉及到上传到私服的均需配置可上传的账号,不过默认一般为:

    <server>
      <id>xxx-snapshot</id>
      <username>deployment</username>
      <password>deployment123</password>
    </server>



7. maven插件

   7.1  将所有的依赖项都包含,生成一个独立的jar包

 

  <build>
    <plugins>
      <!-- any other plugins -->
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
      </plugin>
    </plugins>
  </build>
   

  7.2  springboot 插件

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

8. maven项目构建

比较灵活,简单点就构建多模块modules项目,分解成子项目,只需要在根目录下mvn clean install,maven reactor自动帮你处理编译先后顺序。

随意点就添加depxendency手动一个一个编译,编译顺序自己控制好就行了。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值