Chinaunix首页 | 论坛 | 博客
  • 博客访问: 29943873
  • 博文数量: 708
  • 博客积分: 12163
  • 博客等级: 上将
  • 技术积分: 8240
  • 用 户 组: 普通用户
  • 注册时间: 2007-12-04 20:59
文章分类

全部博文(708)

分类: Java

2009-11-13 17:04:25

我有一个svn的jar库,project有很大一部分是用这部分的jar包,那如何在maven打包编译或mvn install时,一部分是引用maven远程库,一部分是依赖这个svn库呢?
问题补充:
在你maven目录下的conf目录下的settings文件中编辑
你本地库的目录

这个肯定是不行的,我的本地库又不符合maven读取的格式的
 
解决:
svn可以结合apache,webdav成为可以通过http访问的形式
然后在pom里面可以配置远程仓库,配置到对应的地址就可以了

不过建议你不要使用这种方式,最好是在本地架设一个nexus的maven2私服,这样就直接设置到私服上就可以了,nexus可以代理你的请求连接外网,如果本地没有这个jar,私服就会想central服务器请求下载,它下好了之后,然后你这边就有了对应的jar包了,私服上也有缓存,比较节省网络资源,也比较好管理
nexus地址
 
 
 
 
 

我对比了一些maven的私服以后,感觉nexus最好使,把搭建的过程步骤一下吧,我的环境是cent5, tomcat 6
1、下载war包,部署到tomcat中,启动tomcat;
2、访问:;
3、用admin/admin123登录;
4、修改admin的密码,但是不要修改别的属性和修改别的用户信息
5、进入administration中的repositories,依次修改三个type是proxy的项目,将其Download Remote Indexes修改为true;然后邮件他们,分别re-index一下;
6、将你自己机器上的manven缓存(一般是在C:\Documents and Settings\登录名\.m2下面)全部拷贝到/home/你的用户名/sonatype-work/nexus/storage下面的central和releases各一份;
7、修改你本地的(一般是在C:\Documents and Settings\登录名\.m2下面)setting.xml文件改成下面的:

Xml代码 复制代码
  1. <settings>  
  2.       <proxies>  
  3.         <proxy>  
  4.           <id>normalid>  
  5.           <active>trueactive>  
  6.           <protocol>httpprotocol>  
  7.           <username>deploymentusername>  
  8.           <password>deploypassword>  
  9.           <host>172.19.0.177:8080/nexus-1.1.1host>  
  10.           <port>80port>  
  11.           <nonProxyHosts>172.19.0.177:8080/nexus-1.1.1nonProxyHosts>  
  12.         proxy>  
  13.       proxies>  
  14.       <servers>  
  15.       servers>  
  16.       <mirrors>  
  17.          <mirror>  
  18.           <id>nexus-public-snapshotsid>  
  19.           <mirrorOf>public-snapshotsmirrorOf>  
  20.           <url>url>  
  21.         mirror>  
  22.         <mirror>  
  23.             
  24.           <id>nexusid>  
  25.           <mirrorOf>*mirrorOf>  
  26.           <url>url>  
  27.         mirror>  
  28.       mirrors>  
  29.       <profiles>  
  30.         <profile>  
  31.           <id>developmentid>  
  32.           <repositories>  
  33.             <repository>  
  34.               <id>centralid>  
  35.               <url>url>  
  36.               <releases><enabled>trueenabled>releases>  
  37.               <snapshots><enabled>trueenabled>snapshots>  
  38.             repository>  
  39.           repositories>  
  40.          <pluginRepositories>  
  41.             <pluginRepository>  
  42.               <id>centralid>  
  43.               <url>url>  
  44.               <releases><enabled>trueenabled>releases>  
  45.               <snapshots><enabled>trueenabled>snapshots>  
  46.             pluginRepository>  
  47.           pluginRepositories>  
  48.         profile>  
  49.         <profile>  
  50.           <id>public-snapshotsid>  
  51.           <repositories>  
  52.             <repository>  
  53.               <id>public-snapshotsid>  
  54.               <url>url>  
  55.               <releases><enabled>falseenabled>releases>  
  56.               <snapshots><enabled>trueenabled>snapshots>  
  57.             repository>  
  58.           repositories>  
  59.          <pluginRepositories>  
  60.             <pluginRepository>  
  61.               <id>public-snapshotsid>  
  62.               <url>url>  
  63.               <releases><enabled>falseenabled>releases>  
  64.               <snapshots><enabled>trueenabled>snapshots>  
  65.             pluginRepository>  
  66.           pluginRepositories>  
  67.         profile>  
  68.       profiles>  
  69.         <activeProfiles>  
  70.         <activeProfile>developmentactiveProfile>  
  71.       activeProfiles>  
  72. settings>  
 

    将172.19.0.177地址修改为你自己的服务器地址
   
8、在你的项目中的pom.xml中增加一段:

Xml代码 复制代码
  1. <distributionManagement>  
  2.         <repository>  
  3.             <id>repoid>  
  4.             <name>publicname>  
  5.             <url>url>  
  6.         repository>  
  7.         <snapshotRepository>  
  8.             <id>Snapshotsid>  
  9.             <name>Snapshotsname>  
  10.             <url>url>  
  11.         snapshotRepository>  
  12.     distributionManagement>  
 


这样一来经过我的测试,如果你在没有局域网的环境中(也就是没办法访问你的私服),只要将pom里面的那段删除就可以了。

阅读(2725) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~