maven的package和install区别

1,

项目A 以来项目B,   B项目 如果只是执行 clean,package的话,只是打包到B项目的target 下面,  再编译项目A 的时候一览会报编译错误,原因是项目B没有执行install。

所以package 只是打包到target下,   install是打包安装到我的本地maven仓库。


2,

deploy: 打包到私服

在setting.xml文件中增加用户名和密码配置(特别注意这里的ID)

 

复制代码
    <servers>
        
        <server>
            <id>maven-repository-releasesid>
            <username>adminusername>
            <password>admin123password>
        server>
        
        <server>
            <id>maven-repository-snapshotsid>
            <username>adminusername>
            <password>admin123password>
        server>
    servers>
复制代码

 

2、在项目的pom.xml中增加以下内容

复制代码
    <build>
        <plugins>
            
            <plugin>
                <artifactId>maven-source-pluginartifactId>
                <version>2.1version>
                <configuration>
                    <attach>trueattach>
                configuration>
                <executions>
                    <execution>
                        <phase>compilephase>
                        <goals>
                            <goal>jargoal>
                        goals>
                    execution>
                executions>
            plugin>
        plugins>
    build>

    <distributionManagement>
        <repository>
            
            <id>maven-repository-releasesid>
            <url>http://ip:8081/nexus/content/repositories/thirdparty/url>
        repository>
        
        <snapshotRepository>
            <id>maven-repository-snapshotsid>
            <url>http://ip:8081/nexus/content/repositories/thirdpartyurl>
        snapshotRepository>
    distributionManagement>
复制代码

 

3.执行Maven build的deploy命令


————摘自其他博文——————

先设置pom文件里的build信息,可以是maven-compiler-plugin插件

maven目录conf的setting.xml里:

[html]  view plain  copy
  1. servers>    
  2.  <server>    
  3.     <id>releasesid>    
  4.     <username>adminusername>    
  5.     <password>admin123password>    
  6.   server>    
  7.  <server>    
  8.   <id>snapshotsid>    
  9.   <username>adminusername>    
  10.   <password>admin123password>    
  11.   server>    
  12. servers>    

pom文件添加如下,这里的id上面的id要对应,name无所谓

[html]  view plain  copy
  1.     
  2. <distributionManagement>    
  3.     <repository>    
  4.         <id>releasesid>    
  5.         <name>Nexus Release Repositoryname>    
  6.         <url>http://10.1.81.199:8081/nexus/content/repositories/releases/url>    
  7.     repository>    
  8.     <snapshotRepository>    
  9.         <id>snapshotsid>    
  10.         <name>Nexus Snapshot Repositoryname>    
  11.         <url>http://10.1.81.199:8081/nexus/content/repositories/snapshots/url>    
  12.     snapshotRepository>    
  13. distributionManagement>    

没有权限去管理界面查看DeploymentPolicy设置为Allow Redeploy


你可能感兴趣的:(maven)