一、前提条件

#关于maven私服的搭建与maven项目的介绍与部署请参考我的另两篇博文:

http://ylcodes01.blog.51cto.com/5607366/1771650

http://ylcodes01.blog.51cto.com/5607366/1774050


系统环境为:

[root@llyLinux application]# cat /etc/redhat-release 
CentOS release 6.7 (Final)
[root@llyLinux application]# uname -r
2.6.32-573.el6.x86_64


需要准备的安装包为:

subversion-1.6.1.tar.gz
subversion-deps-1.6.1.tar.gz 
apache-maven-3.3.3-bin.tar.gz


二、SVN部分

[root@softtest application]# pwd
/application

#上传subversion-1.6.1.tar.gz和subversion-deps-1.6.1.tar.gz到此目录下
[root@softtest application]# tar xf subversion-1.6.1.tar.gz
[root@softtest application]# tar xf subversion-deps-1.6.1.tar.gz 

#创建编译路径
[root@softtest application]# mkdir subversion
[root@softtest application]# ls -ld subversion
drwxr-xr-x 2 root root 4096 Sep  1 11:46 subversion

[root@softtest application]# cd subversion-1.6.1

[root@softtest subversion-1.6.1]#./configure --prefix=/application/subversion
checking openssl/opensslv.h usability... no
checking openssl/opensslv.h presence... no
checking for openssl/opensslv.h... no
configure: error: We require OpenSSL; try --with-openssl
configure failed for serf

#如果编译结束出现上述错误,那么需要安装下述软件之后再次编译
[root@softtest subversion-1.6.1]# yum install openssl openssl-devel -y

[root@softtest subversion-1.6.1]#make && make install

[root@softtest subversion-1.6.1]#cd /application/subversion/bin

[root@softtest bin]# svnserve --version
svnserve, version 1.6.11 (r934486)
   compiled Jul 23 2015, 23:48:52

Copyright (C) 2000-2009 CollabNet.
Subversion is open source software, see http://subversion.tigris.org/
This product includes software developed by CollabNet (http://www.Collab.Net/).

The following repository back-end (FS) modules are available:

* fs_base : Module for working with a Berkeley DB repository.
* fs_fs : Module for working with a plain file (FSFS) repository.

Cyrus SASL authentication is available.


[root@softtest bin]# cd /application/

[root@softtest application]# ln -s /application/subversion /application/svn

[root@softtest application]# ls svn/
bin  build-1  include  lib  share

[root@softtest application]# echo "PATH=/application/svn/bin:$PATH" >> /etc/profile         

[root@softtest application]# svnserve --version

[root@softtest application]# tail -1 /etc/profile
PATH=/application/svn/bin:/application/maven/bin:/application/jdk/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin

[root@softtest application]# source /etc/profile                  

[root@softtest application]# svnserve --version


#开启SVN服务进程

[root@softtest application]# svnserve -d -r /application/

这个命令的作用是开启svn服务进程,并且把/application/目录作为我们的svn服务的根目录。以后,当我们要在客户端checkout代码的时候,svn服务进程就会从这里开始进行查询,类似于apache的/var/www/目录的作用。运行如下命令检查svn服务是否开启了。

[root@svnnexus /]# ps -ef|grep svn|grep -v grep
root     115292      1  0 16:19 ?        00:00:00 svnserve -d -r /application/


#创建SVN版本库
[root@softtest application]# mkdir /application/svnrepos -p
[root@softtest application]# svnadmin create /application/svnrepos


#修改SVN版本库配置文件,修改的配置文件内容,务必按照下面的弄,千万不要有多余空格
[root@softtest application]# cd svnrepos
[root@softtest svnrepos]# ls
conf  db  format  hooks  locks  README.txt
[root@softtest svnrepos]# cd conf/

#svn服务配置文件,该文件版本库目录的conf目录下
[root@softtest conf]# cp svnserve.conf svnserve.conf.ori
[root@softtest conf]# egrep "anon-access|auth-access|password-db|authz-db" /application/svnrepos/conf/svnserve.conf
# anon-access = read
anon-access = none#使非授权用户无法访问
# auth-access = write
auth-access = write#使授权用户有写权限
### The password-db option controls the location of the password
# password-db = passwd
password-db = passwd#指明密码文件路径
authz-db = authz#指定权限配置文件名,通过该文件可以实现以路径为基础的访问控制。

#修改SVN版本库用户,用户名口令文件,该文件名在文件svnserve.conf中指定,缺省为同目录下的
[root@softtest conf]# cp passwd passwd.ori
[root@svnnexus conf]# cat passwd
### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.

[users]
# harry = harryssecret
# sally = sallyssecret
#在最下面按照格式加入svn的用户名和密码,自定义即可
admin = admin 
zhangsan= zhangsanpwd 

#权限配置文件,该文件名也在文件svnserve.conf中指定,缺省为同目录下的
[root@softtest conf]# cp authz authz.ori
[root@svnnexus conf]# cat authz 
### This file is an example authorization file for svnserve.
### Its format is identical to that of mod_authz_svn authorization
### files.
### As shown below each section defines authorizations for the path and
### (optional) repository specified by the section name.
### The authorizations follow. An authorization line can refer to:
###  - a single user,
###  - a group of users defined in a special [groups] section,
###  - an alias defined in a special [aliases] section,
###  - all authenticated users, using the '$authenticated' token,
###  - only anonymous users, using the '$anonymous' token,
###  - anyone, using the '*' wildcard.
###
### A match can be inverted by prefixing the rule with '~'. Rules can
### grant read ('r') access, read-write ('rw') access, or no access
### ('').

[aliases]
# joe = /C=XZ/ST=Dessert/L=Snake City/O=Snake Oil, Ltd./OU=Research Institute/CN=Joe Average

[groups]
admin = admin 
zhangsan=zhangsan
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
# [/foo/bar]
# harry = rw
# &joe = r
# * =
# [repository:/baz/fuz]
# @harry_and_sally = rw
# * = r
#最下面加入,这三行的意思是,目录[svnrepos:/](代码根目录,对应svnadmin的版本库名称)下的所有文件,如果没有特殊约定的话,zhangsan用户将具有读(r)和写(w)的权限。
[svnrepos:/]
@admin = rw 
@zhangsan = rw

#修改完svn配置文件,记得杀掉SVN进程后,重新开启SVN进程svnserve -d -r /application/


#windows客户端连接

shell 拉代码 maven 打包 linux maven打包_shell 拉代码 maven 打包

shell 拉代码 maven 打包 linux maven打包_数据库_02

shell 拉代码 maven 打包 linux maven打包_shell 拉代码 maven 打包_03

右键SVN,点add

shell 拉代码 maven 打包 linux maven打包_java_04


shell 拉代码 maven 打包 linux maven打包_数据库_05

shell 拉代码 maven 打包 linux maven打包_java_06

#注意,上传的文件并没有到/application/svnrepos目录下,而是存在对应的SVN库中了,

个人理解,如果创建不同的版本库,那么上传的文件就会存在不同版本库的目录中。



三、MAVEN部分

#上传apache-maven-3.3.3-bin.tar.gz
[root@softtest application]# tar xf apache-maven-3.3.3-bin.tar.gz 
[root@softtest application]# ln -s /application/apache-maven-3.3.3 /application/maven
#注意此处的maven版本必须是JDK1.7,maven版本和java版本的使用参照图请参考http://maven.apache.org/docs/history.html
[root@softtest application]# /application/maven/bin/mvn -version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T19:57:37+08:00)
Maven home: /application/maven
Java version: 1.7.0_79, vendor: Oracle Corporation
Java home: /application/jdk1.7.0_79/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "2.6.32-573.el6.x86_64", arch: "amd64", family: "unix"

[root@softtest application]# echo "PATH=/application/maven/bin:$PATH" >> /etc/profile
[root@softtest application]# tail -1 /etc/profile
PATH=/application/svn/bin:/application/maven/bin:/application/jdk/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin
[root@softtest application]# mvn -version


#创建本地maven仓库(放置maven项目依赖的jar包,因为在maven项目编译的时候,会到这个目录里来查找,如果没找到对应的jar包,那么会到maven私服或互联网maven仓库中下载)

[root@softtest application]# cd /home/
[root@softtest home]# mkdir /home/warehouse -p

#上传windows本地maven仓库的jar包到这个目录下

[root@softtest warehouse]# ls
aopalliance  classworlds  commons-beanutils  commons-codec       commons-io    commons-logging  javax  log4j  net  stax      xpp3
c3p0         com          commons-cli        commons-fileupload  commons-lang  dom4j            junit  mysql  org  xml-apis
[root@softtest warehouse]# ls commons-io/commons-io/2.4/commons-io-2.4.jar
commons-io/commons-io/2.4/commons-io-2.4.jar


#编译maven项目

[root@softtest warehouse]# cd /home/sourceCode/jy-cps-parent/jy-cps-mis/
[root@softtest jy-cps-mis]# mvn clean install
[root@softtest jy-cps-mis]# ls
doc  pom.xml  src  target

#最终会生成对应的war包

[root@softtest jy-cps-mis]# ls target/jy-cps-mis-0.0.1-SNAPSHOT.war 
target/jy-cps-mis-0.0.1-SNAPSHOT.war


转载于:https://blog.51cto.com/ylcodes01/1845228