Maven 之setting.xml pom.xml

1)、 配置Maven 从私服上下载构件

a、在POM.xml文件中配置


	
		central.maven.com
		mapbar central mirror.
		http://192.168.1.252:8081/nexus/content/repositories/central/
	
	
		3rd.mapbar.com
		mapbar thirdparty central mirror.
		http://192.168.1.252:8081/nexus/content/repositories/thirdparty/
	
	
		public.mapbar.com
		mapbar tech API maven mirror.
		http://192.168.1.252:8081/nexus/content/groups/public/
	
	
		releases.mapbar.com
		mapbar thirdparty central mirror.
		http://192.168.1.252:8081/nexus/content/repositories/releases/
	

这样的配置只对Maven项目有效,在实际引用中,我们想通过一次配置就能让本机所有的Maven项目都能使用自己的Maven私服。这个时候就要用settings.xml 文件。改文件对本机所有的Maven项目有效。配置如下:


	
		nexus
		
			
				nexus
				Nexus
				http://192.168.53.55:8081/nexus/content/groups/public/
				
					true
				
				
					true
				
			
		
		
			
				nexus
				Nexus
				http://192.168.53.55:8081/nexus/content/groups/public/
				
					true
				
				
					true
				
			
		
	


	nexus


2)、配置自动发布构件到私服

POM.XML 配置:


	  
	    releases
	    http://localhost:8081/nexus/content/repositories/thirdparty/
	  

在命令行键入:mavn  deploy 则构件自动发布到本地和上传到私服 http://localhost:8081/nexus/content/repositories/thirdparty 这个目录下


需要注意2点:

1、发布的版本类型必须和nexus里的Policy类型一致。

2、setting.xml 文件必须配置servers,其中id必须和repository下的id一致。


		
			releases
			admin
			admin123
		
		
			snapshots
			admin
			admin123
		
		
			deploymentRepo
			admin
			admin123
		
	



3)、在 中配置项目构建信息,生成doc,source  


	
			
			
			
				org.apache.maven.plugins
				maven-source-plugin
				
					
						attach-sources
						
							jar
						
					
				
			
			
			
				org.apache.maven.plugins
				maven-javadoc-plugin
				
					
						attach-javadocs
						
							jar
						
					
				
			
		
	


输入命令:mvn install

 在target目录下生成了

MavenTest-0.0.1-release.jar           --.class文件

MavenTest-0.0.1-release-sources.jar    --.java 文件

MavenTest-0.0.1-release-javadoc.jar   --doc 文件

 

 

你可能感兴趣的:(Management),maven,项目构建,javadoc,build,api)