取maven copy部分

mvn deploy:deploy-file -DgroupId=com.mycompany -DartifactId=my-project -Dversion=1.0.0 -Dpackaging=jar -Dfile=myproject-name.jar -Durl=http://localhost:8081/nexus/content/repositories/release/ -DrepositoryId=releasemvn install:install-file -Dfile=/home.jar -DgroupId=xx -DartifactId=xx -Dversion=1.0 -Dpackaging=jar
这句话可以将下载的jar包,放到本地仓库中

 maven实际应用

  4.0.0

  com.xuanwu
  sxt_mtoserver
  1.0-SNAPSHOT
  jar

  sxt_mtoserver
  http://maven.apache.org

  
      
    UTF-8
    deploy
  
  
  
      
          
          
              org.apache.maven.plugins
              maven-compiler-plugin
              2.3.2
              
                1.5
                1.5
            
          
          
          
          
          
          
           
          
              org.apache.maven.plugins
              maven-resources-plugin
              2.5
              
                    
                        copy-resources
                        package
                        
                            copy-resources
                        
                        
                            UTF-8
                            ${project.build.directory}/${project.deploy}/conf
                            
                            
                                
                                    src/main/resources/
                                    
                                        *.xml
                                        *.properties
                                        *.conf
                                    
                                
                            
                        
                    
                    
                        copy-sh
                        package
                        
                            copy-resources
                        
                        
                            UTF-8
                            ${project.build.directory}/${project.deploy}/
                            
                            
                                
                                    src/main/resources/
                                    
                                        *.sh
                                        *.pl
                                        *.bat
                                    
                                
                            
                        
                    
                
          
          
          
          
          
              org.apache.maven.plugins
              maven-jar-plugin
              2.3.2
               
                 
                      
                      false
                     
                        
                           com.xuanwu.mtoserver.util.Test    
                       
                 
             
              
                    
                        jarexclude
                        package
                        
                            jar
                        
                        
                            ${project.build.directory}/${project.deploy}/lib
                            
                                *.xml
                                *.pl
                                *.sql
                                *.properties
                                *.bat
                                *.conf
                                *.sh
                                *.doc
                            
                        
                    
            
          
          
          
          
           
           
           
           
          
          
              org.apache.maven.plugins
              maven-dependency-plugin
              2.3
              
                    
                        copy-dependencies
                        package
                        
                            copy-dependencies
                        
                        
                            ${project.build.directory}/${project.deploy}/lib
                            false
                            false
                            true
                        
                    
            
          
          
      
  
  
    
      junit
      junit
      3.8.1
      test
    
    
    
        axis
        axis
        1.4
        jar
        compile
    
    
        axis
        axis-jaxrpc
        1.4
        jar
        compile
    
    
        commons-discovery
        commons-discovery
        20040218.194635
        jar
        compile
    
    
        commons-logging
        commons-logging
        1.1.1
        jar
        compile
    
    
        axis
        axis-saaj
        1.4
        jar
        compile
    
    
        axis
        axis-wsdl4j
        1.5.1
        jar
        compile
    
  



 
  

原地址:http://www.blogjava.net/toby/archive/2011/11/01/362460.html

maven工程编译并生成可执行JAR包命令
2012-02-03 09:54 提问者: 储流香 |浏览次数:3230次

在JAVA持续集成构建中,需要从SVN check out的代码编译并打成可执行JAR包,高手告诉我maven命令如何?

我用mvn compile package或mvn jar:jar都能打成jar包,但不能执行

问题补充:

利用HUDSON+MAVEN编译打包java maven工程,打包成可执行的JAR包。在HUDSON中需要填写maven命令。我想知道的是打可执行jar包的maven命令。
我的pom.xml中添加了:
maven-assembly-plugin jar-with-dependencies mainClass>com.ImageViewer.dao.ImageViewer               

目前的mvn命令是:clean assembly:assembly
但是build时报错:mavenExecutionResult exceptions not empty
org.apache.maven.InternalErrorException: Internal error: ava.lang.NullPointerException
换成jar:jar打成的jar包不能执行。

我来帮他解答
满意回答
2012-02-03 15:28



	org.apache.maven.plugins
	maven-compiler-plugin
	2.3.2
	
		1.6
		1.6
		UTF-8
	


	org.apache.maven.plugins
	maven-jar-plugin
	
	
	
	true
	lib/
	com.abc.ABCTest    -->入口类名
	
	
	


	org.apache.maven.plugins
	maven-dependency-plugin
	
	
	copy
	install
	
		copy-dependencies
	
	
	${project.build.directory}/lib  -->拷贝所以依赖存放位置
	
	
	

 

然后再用mvn clean install 装配一下,打出的jar包就可以运行







maven deploy到nexus报错:Return code is: 401, ReasonPhrase:Unauthorized

分类: maven 557人阅读 评论(2) 收藏 举报

提交到nexus时候报错:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project *: Failed to deploy artifacts: Could not transfer artifact *:jar:1.0 from/to releases (http://10.1.81.199:8081/nexus/content/repositories/releases/): Failed to transfer file: http://10.1.81.199:8081/nexus/content/repositories/releases/com/cs2c/security-management-client* /1.0/*-1.0.jar. Return code is: 401, ReasonPhrase:Unauthorized.

原来是没有配置认证。

maven目录conf的setting.xml里,

  1.   <server>  
  2.     <id>releasesid>  
  3.     <username>adminusername>  
  4.     <password>admin123password>  
  5.   server>  
  6.  <server>  
  7.   <id>snapshotsid>  
  8.   <username>adminusername>  
  9.   <password>admin123password>  
  10.   server>  
  11. servers>  

用户名和密码都是nexus的。再次deploy即可。

注意这里的id要和pom.xml里远程deploy的地址对应一致,我的pom.xml里配置:

  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>  



如果这里不配置,会报错: 报错:Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.5:deploy (default-deploy) on project git-demo: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
 
  
 
 

你可能感兴趣的:(java管理工具)