打开皇冠足球比分球网比分后显示网络问题或404错误

用户名:xingliguang
文章数:141
评论数:13
访问量:58241
注册日期:
阅读量:1297
阅读量:3317
阅读量:429665
阅读量:1117642
51CTO推荐博文
一、概述上一篇文章介绍了Jenkins结合svn来构建jar包,本文介绍另一种代码提交的方式git,并结合maven来构建代码包。实验环境:IP:&10.0.90.27&系统:&Centos6.6&x86_64软件包:Jenkins&&2.9
Tomcat&&&8.0.36
JDK&&&&&&8.92
maven&&&&3.3.9
git二、安装步骤1、安装jdk#rpm&-ivh&jdk-8u92-linux-x64.rpm&
Preparing...&&&&&&&&&&&&&&&&###########################################&[100%]
&&&1:jdk1.8.0_92&&&&&&&&&&&&###########################################&[100%]
Unpacking&JAR&files...
&&&&&&&&tools.jar...
&&&&&&&&plugin.jar...
&&&&&&&&javaws.jar...
&&&&&&&&deploy.jar...
&&&&&&&&rt.jar...
&&&&&&&&jsse.jar...
&&&&&&&&charsets.jar...
&&&&&&&&localedata.jar...2、安装tomcat#tar&xf&apache-tomcat-8.0.36.tar.gz&&-C&/usr/local/
#cd&/usr/local/
#ln&-sv&apache-tomcat-8.0.36&tomcat
#cd&tomcat
#./bin/startup.sh&
Using&CATALINA_BASE:&&&/usr/local/tomcat
Using&CATALINA_HOME:&&&/usr/local/tomcat
Using&CATALINA_TMPDIR:&/usr/local/tomcat/temp
Using&JRE_HOME:&&&&&&&&/usr
Using&CLASSPATH:&&&&&&&/usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
Tomcat&started.
访问测试:
在浏览器输入http://10.0.90.27:8080,出现tomcat的默认网页,表示安装成功。3、安装Jenkins(安装方式是直接解压到tomcat中)将jenkins.war包拷贝的/usr/local/tomcat/webapps目录然后再浏览器访问:http://10.0.90.27:8080/jenkins/ 显示下面界面根据提示从/root/.jenkins/secrets/initialAdminPassword文件中获取密码,然后继续,会看到如下界面:然后就按照默认的选择(Install suggested plugins),继续下一步,会看到安装Plugin的界面:安装Plugin的过程会花费一些时间,请耐心等待……PS:如果一直处于安装状态(可能会因为网络原因,有些个Plugin安装不了),可以刷新一下浏览器,如果刷新之后提示你安装失败,你可以点击提示的“Retry”,继续。安装好Plugin之后,会让你创建一个admin用户,你可以自定义如下图:也可以继续使用admin用户,如下红方框中的按钮(我这里是创建了一个普通的admin用户liguang):创建好之后,点击“Save and Finish”按钮,会弹出如下页面:然后点击 “Start using Jenkins”,就会看到安装好的Jenkins界面了可以查看之前安装了哪些插件,哪些安装成功了,哪些没有安装成功,方法:“系统管理”--“管理插件”,会看到插件的界面,可以根据情况操作。注意:假如你想使用svn来管理代码,但是svn插件没有安装,就会在创建的新项目进行配置的时候,“代码管理”设置部分显示为None,如下:这个时候,你就需要安装svn插件了。4、Jenkins安装插件“系统管理”--“管理插件”--“可选插件”,然后在右上角的“过滤”长方框中输入svn,就会看到很多svn相关的插件,选择安装如下的插件即可:选择“直接安装”或者“下载待重启后安装”都可以,我这里选择第二个,然后会看到如下界面,先是处于“等待”的状态,过一会儿就是“安装中”的状态。安装好之后,提示如下图:然后重新启动tomcat,刷新浏览器,再到“插件管理”查看svn的安装情况,如下表示安装成功:PS:这时,在到test_app项目中的“源码管理”部分,就会看到“None”和“Subversion”都存在了!但是很多时候我们也会用到CVS或者git来拉取代码,所以需要安装这2个插件。安装CVS(CVS Plug-in)和git(Git plugin)插件,方法一样,需要重启tomcat生效,安装完成之后,在项目配置的时候,就可以看到了,如下:这样就有4种方式进行源码的管理了!5、查看Jenkins的Global Tool Configuration“系统管理”---“Global Tool Configuration”,如下图:根据提示可以看出是Jenkins服务器没有安装git,找不到git命令,后面会介绍安装git的方式。三、配置Jenkins通过git拉取代码注:gitlab的安装配置这里不介绍了(如果和Jenkins安装到同一台服务器,需要注意端口不要冲突了)1、在Jenkins服务器生成key#ssh-keygen&-t&rsa&&&&&&&##不需要设置密码,一路回车即可
Generating&public/private&rsa&key&pair.
Enter&file&in&which&to&save&the&key&(/root/.ssh/id_rsa):&
Enter&passphrase&(empty&for&no&passphrase):&
Enter&same&passphrase&again:&
Your&identification&has&been&saved&in&/root/.ssh/id_rsa.
Your&public&key&has&been&saved&in&/root/.ssh/id_rsa.pub.
The&key&fingerprint&is:
5a:f1:2f:5c:78:26:26:0d:a4:43:e7:bf:c8:a0:91:e9&root@localhost.localdomain
The&key's&randomart&image&is:
+--[&RSA&2048]----+
|&&&&&&.&o&&&&&&&&|
|&&&&&.&=&&&&&&&&&|
|&&&&&&o&+&&&&&&&&|
|&&&&&o&.&*&.&&&&&|
|&&&&+&.&S&B&+&&&&|
|&&&.&o&=&=&B&&&&&|
|&&&&E&.&o&+&.&&&&|
|&&&&&&&&&&&.&&&&&|
|&&&&&&&&&&&&&&&&&|
+-----------------+2、在Jenkins服务器安装git客户端命令,我这里直接yum安装#yum&install&git&&-y
查看版本:
#git&--version
git&version&1.7.1安装好之后,再到Global Tool Configuration查看,就不会有二.5提示的错误了。顺便为其设置一个名称,Name 设置为git1.7.1 ,Path to Git executable 保持不变即可。3、查看gitlab上Project的信息(我这里用的是之前搭建好的gitlab,地址是10.0.18.173),这里以server1/CSS项目为例:红方框中给出的是访问该代码的方式,我们用的是git,所以需要配置为git@10.0.18.173:server1/css.git,也可以是域名:git@:server1/css.git4、在Jenkins的项目中配置,以test_app为例子,不过配置好之后,遇到了如下的问题:原因:根据错误提示,发现是没有权限到gitlab服务器端拉取代码,需要将Jenkins服务端刚才生成的id_rsa.pub配置在某一个可以登录gitlab用户的SSH Keys 中,方法如下:使用一个用户登录到gitlab,并且这个用户对gitlab上的所有项目有读写权限,然后添加Jenkins的key点击右上方的“Profile settings”,在弹出的页面再点击“SSH Keys”,会弹出如下界面:点击“Add SSH Key”,自定义Title,将key粘贴到下面的方框中,点击“Add key”,如下图:然后刷新Jenkins页面,上面三.4出错的页面,就不会再报错了!PS:如果安装好Jenkins之后,你配置了普通用户并且设置了邮箱,添加好key之后,系统会发邮件通知你,内容如下:5、为项目添加代码分支首先要从gitlab上查看代码分支,然后在Jenkins的每个项目中添加分支,以test_app项目为例子,如下:、添加好之后要apply和save!PS:每次构建只能配置一个分支!6、其他配置:可以配置丢弃旧的构建,因为保留太多没有用。四、配置Jenkins通过maven打包代码1、安装maven插件,名称为:Maven Integration plugin,如下:然后点击“直接安装”,需要等一些时间才能安装完成,然后重启tomcat生效!PS:安装的时候遇到一个问题,安装3次都不成功,提示失败,如下图:然后ping域名updates.jenkins-ci.org是不通的,然后换用浏览器访问http://ftp.yz.yamagata-u.ac.jp/pub/misc/jenkins/plugins/maven-plugin/2.13/是可以访问的,然后我反复尝试了5-6次,最后安装成功了,无解!!!2、在Jenkins上安装maven#tar&xf&apache-maven-3.3.9-bin.tar.gz&-C&/usr/local/
#cd&/usr/local/
#&ln&-sv&apache-maven-3.3.9/&maven
`maven'&-&&`apache-maven-3.3.9/'
设置环境变量
#vi&/etc/profile&&&#在末尾添加
MAVEN_HOME=/usr/local/maven
export&MAVEN_HOME
export&PATH=${PATH}:${MAVEN_HOME}/bin
执行source,使设置生效
#source&/etc/profile
查看安装maven的信息
Apache&Maven&3.3.9&(bb52da5a3f4c23dc5;&T00:41:47+08:00)
Maven&home:&/usr/local/maven
Java&version:&1.8.0_92,&vendor:&Oracle&Corporation
Java&home:&/usr/java/jdk1.8.0_92/jre
Default&locale:&en_US,&platform&encoding:&UTF-8
OS&name:&"linux",&version:&"2.6.32-504.el6.x86_64",&arch:&"amd64",&family:&"unix"在Jenkins的web界面配置Maven版本和路径,选择“系统管理”--“Global Tool Configuration”,配置为如下:然后“Apply”--“Save”3、使用Maven创建项目无论是学习语言还是框架,先来一个Hello World基本上已经是套路了,这里也通过构建一个Hello World项目来了解如何使用Maven。a、首先通过maven创建helloworld项目#mvn&archetype:create&-DgroupId=helloworld&-DartifactId=helloworld
[INFO]&Scanning&for&projects...
Downloading:&https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
Downloaded:&https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom&(4&KB&at&0.2&KB/sec)
Downloading:&https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/22/maven-plugins-22.pom
Downloaded:&https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-plugins/22/maven-plugins-22.pom&(13&KB&at&2.0&KB/sec)
Downloading:&https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/21/maven-parent-21.pom
Downloaded:&https://repo.maven.apache.org/maven2/org/apache/maven/maven-parent/21/maven-parent-21.pom&(26&KB&at&6.1&KB/sec)
Downloading:&https://repo.maven.apache.org/maven2/org/apache/apache/10/apache-10.pom
Downloaded:&https://repo.maven.apache.org/maven2/org/apache/apache/10/apache-10.pom&(15&KB&at&6.7&KB/sec)
Downloading:&https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.jar
Downloaded:&https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.jar&(25&KB&at&6.5&KB/sec)
………………&&&##省略
Downloaded:&https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-archetype-plugin/2.4/maven-archetype-plugin-2.4.jar&(92&KB&at&2.3&KB/sec)
[INFO]&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
[INFO]&------------------------------------------------------------------------
[INFO]&Building&Maven&Stub&Project&(No&POM)&1
[INFO]&------------------------------------------------------------------------
[INFO]&---&maven-archetype-plugin:2.4:create&(default-cli)&@&standalone-pom&---
Downloading:&
………………&##省略
Downloaded:&https://repo.maven.apache.org/maven2/org/codehaus/groovy/groovy/1.8.3/groovy-1.8.3.jar&(5394&KB&at&7.3&KB/sec)
[INFO]&------------------------------------------------------------------------
[INFO]&BUILD&FAILURE
[INFO]&------------------------------------------------------------------------
[INFO]&Total&time:&27:02&min
[INFO]&Finished&at:&T19:04:30+08:00
[INFO]&Final&Memory:&12M/30M
[INFO]&------------------------------------------------------------------------
[ERROR]&Failed&to&execute&goal&org.apache.maven.plugins:maven-archetype-plugin:2.4:create&(default-cli)&on&project&standalone-pom:&Unable&to&parse&configuration&of&mojo&org.apache.maven.plugins:maven-archetype-plugin:2.4:create&for&parameter&#:&Cannot&create&instance&of&interface&org.apache.maven.artifact.repository.ArtifactRepository:&org.apache.maven.artifact.repository.ArtifactRepository.&init&()&-&&[Help&1]
[ERROR]&To&see&the&full&stack&trace&of&the&errors,&re-run&Maven&with&the&-e&switch.
[ERROR]&Re-run&Maven&using&the&-X&switch&to&enable&full&debug&logging.
[ERROR]&For&more&information&about&the&errors&and&possible&solutions,&please&read&the&following&articles:
[ERROR]&[Help&1]&http://cwiki.apache.org/confluence/display/MAVEN/PluginConfigurationException&
可以看到,是有ERROR出现,google寻找原因,说法不一,然后尝试了如下方式:
原因:archetype:create命令已经过期,需要使用&archetype:generate&来进行代替
#mvn&archetype:generate&&-DgroupId=helloworld&-DartifactId=helloworld&
[INFO]&Scanning&for&projects...
[INFO]&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
[INFO]&------------------------------------------------------------------------
[INFO]&Building&Maven&Stub&Project&(No&POM)&1
[INFO]&------------------------------------------------------------------------
[INFO]&&&&&maven-archetype-plugin:2.4:generate&(default-cli)&&&generate-sources&@&standalone-pom&&&&
[INFO]&&&&&maven-archetype-plugin:2.4:generate&(default-cli)&&&generate-sources&@&standalone-pom&&&&
[INFO]&---&maven-archetype-plugin:2.4:generate&(default-cli)&@&standalone-pom&---
[INFO]&Generating&project&in&Interactive&mode
………………&&&&##信息太多,省略
………………
1611:&remote&-&&uk.co.solong:angular-spring-archetype&(So&Long&archetype&for&RESTful&spring&services&with&an&AngularJS&frontend.&Includes&debian&deployment)
1612:&remote&-&&us.fatehi:schemacrawler-archetype-maven-project&(-)
1613:&remote&-&&us.fatehi:schemacrawler-archetype-plugin-command&(-)
1614:&remote&-&&us.fatehi:schemacrawler-archetype-plugin-dbconnector&(-)
1615:&remote&-&&us.fatehi:schemacrawler-archetype-plugin-lint&(-)
Choose&a&number&or&apply&filter&(format:&[groupId:]artifactId,&case&sensitive&contains):&799:&Choose&org.apache.maven.archetypes:maven-archetype-quickstart&version:&
1:&1.0-alpha-1
2:&1.0-alpha-2
3:&1.0-alpha-3
4:&1.0-alpha-4
Choose&a&number:&6:&Downloading:&https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.1/maven-archetype-quickstart-1.1.jar
Downloaded:&https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.1/maven-archetype-quickstart-1.1.jar&(7&KB&at&3.7&KB/sec)
Downloading:&https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.1/maven-archetype-quickstart-1.1.pom
Downloaded:&https://repo.maven.apache.org/maven2/org/apache/maven/archetypes/maven-archetype-quickstart/1.1/maven-archetype-quickstart-1.1.pom&(2&KB&at&4.1&KB/sec)
[INFO]&Using&property:&groupId&=&helloworld
[INFO]&Using&property:&artifactId&=&helloworld
Define&value&for&property&'version':&&1.0-SNAPSHOT:&:&&&&##执行到此处停止了,回车即可
[INFO]&Using&property:&package&=&helloworld
Confirm&properties&configuration:
groupId:&helloworld
artifactId:&helloworld
version:&1.0-SNAPSHOT
package:&helloworld
&Y:&:&&&&&##输入Y,回车
[INFO]&----------------------------------------------------------------------------
[INFO]&Using&following&parameters&for&creating&project&from&Old&(1.x)&Archetype:&maven-archetype-quickstart:1.1
[INFO]&----------------------------------------------------------------------------
[INFO]&Parameter:&basedir,&Value:&/root
[INFO]&Parameter:&package,&Value:&helloworld
[INFO]&Parameter:&groupId,&Value:&helloworld
[INFO]&Parameter:&artifactId,&Value:&helloworld
[INFO]&Parameter:&packageName,&Value:&helloworld
[INFO]&Parameter:&version,&Value:&1.0-SNAPSHOT
[INFO]&project&created&from&Old&(1.x)&Archetype&in&dir:&/root/helloworld
[INFO]&------------------------------------------------------------------------
[INFO]&BUILD&SUCCESS
[INFO]&------------------------------------------------------------------------
[INFO]&Total&time:&11:33&min
[INFO]&Finished&at:&T10:03:37+08:00
[INFO]&Final&Memory:&14M/49M
[INFO]&------------------------------------------------------------------------
b、在当前目录查看helloworld项目生成的目录,如下:
#tree&helloworld/
helloworld/
├──&pom.xml
└──&src
&&&&├──&main
&&&&│&&&└──&java
&&&&│&&&&&&&└──&helloworld
&&&&│&&&&&&&&&&&└──&App.java
&&&&└──&test
&&&&&&&&└──&java
&&&&&&&&&&&&└──&helloworld
&&&&&&&&&&&&&&&&└──&AppTest.java
7&directories,&3&file其中src/main/java是源码目录,src/test/java是测试文件目录,到这些目录可以看到App.java中已经写好了一个Hello World程序,而AppTest中是Junit单元测试的代码,至于pom.xml,则给出了项目的一些基本信息以及依赖关系。看一下App.java和AppTest.java内容:#cat&App.java&
&*&Hello&world!
public&class&App&
&&&&public&static&void&main(&String[]&args&)
&&&&&&&&System.out.println(&"Hello&World!"&);
#cat&AppTest.java&
import&junit.framework.T
import&junit.framework.TestC
import&junit.framework.TestS
&*&Unit&test&for&simple&App.
public&class&AppTest&
&&&&extends&TestCase
&&&&&*&Create&the&test&case
&&&&&*&@param&testName&name&of&the&test&case
&&&&public&AppTest(&String&testName&)
&&&&&&&&super(&testName&);
&&&&&*&@return&the&suite&of&tests&being&tested
&&&&public&static&Test&suite()
&&&&&&&&return&new&TestSuite(&AppTest.class&);
&&&&&*&Rigourous&Test&:-)
&&&&public&void&testApp()
&&&&&&&&assertTrue(&true&);
}再看一下pom.xml文件#cat&pom.xml&
&project&xmlns="http://maven.apache.org/POM/4.0.0"&xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
&&xsi:schemaLocation="http://maven.apache.org/POM/4.0.0&http://maven.apache.org/xsd/maven-4.0.0.xsd"&
&&&modelVersion&4.0.0&/modelVersion&
&&&groupId&helloworld&/groupId&
&&&artifactId&helloworld&/artifactId&
&&&version&1.0-SNAPSHOT&/version&
&&&packaging&jar&/packaging&
&&&name&helloworld&/name&
&&&url&http://maven.apache.org&/url&
&&&properties&
&&&&&project.build.sourceEncoding&UTF-8&/project.build.sourceEncoding&
&&&/properties&
&&&dependencies&
&&&&&dependency&
&&&&&&&groupId&junit&/groupId&
&&&&&&&artifactId&junit&/artifactId&
&&&&&&&version&3.8.1&/version&
&&&&&&&scope&test&/scope&
&&&&&/dependency&
&&&/dependencies&
&/project&解释:在pom.xml文件中,首先描述了项目的定义,groupId:artifactId:version:packaging这个四元组能够唯一标记一个项目。我们不仅可以用这个四元组来标记我们的项目,也可以用来标记其它的项目,比如用来描述项目依赖关系。properties中定义了项目的属性,也可以在这里定义变量并在其它的地方引用。至于最后的dependencies,则是描述了项目的依赖关系,Maven会根据依赖关系自动下载相应的文件并在编译时使用。在大型项目开发中,往往会将其分成若干个子项目,每个子项目都有着自己的的pom.xml,它们与父pom.xml之间相当于继承的关系。可以说,pom.xml文件的配置是整个Maven的核心重点,也是学习Maven过程中需要详细了解的内容。这里只给出了最简单的配置样例,详细了解可以查看官方文档。c、编译并运行helloworld项目(需要联网,因为Maven会自动下载依赖包。)#cd&/root/helloworld/
#mvn&package
[INFO]&Scanning&for&projects...
[INFO]&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
[INFO]&------------------------------------------------------------------------
[INFO]&Building&helloworld&1.0-SNAPSHOT
[INFO]&------------------------------------------------------------------------
Downloading:&
………………&&##信息太多,此处省略
Downloaded:&https://repo.maven.apache.org/maven2/org/apache/maven/surefire/surefire-junit3/2.12.4/surefire-junit3-2.12.4.jar&(26&KB&at&23.5&KB/sec)
-------------------------------------------------------
&T&E&S&T&S
-------------------------------------------------------
Running&helloworld.AppTest
Tests&run:&1,&Failures:&0,&Errors:&0,&Skipped:&0,&Time&elapsed:&0.001&sec
Tests&run:&1,&Failures:&0,&Errors:&0,&Skipped:&0
[INFO]&---&maven-jar-plugin:2.4:jar&(default-jar)&@&helloworld&---
Downloading:&
………………&&##此处省略
[INFO]&Building&jar:&/root/helloworld/target/helloworld-1.0-SNAPSHOT.jar
[INFO]&------------------------------------------------------------------------
[INFO]&BUILD&SUCCESS
[INFO]&------------------------------------------------------------------------
[INFO]&Total&time:&01:46&min
[INFO]&Finished&at:&T10:31:06+08:00
[INFO]&Final&Memory:&16M/40M
[INFO]&------------------------------------------------------------------------&
可以看到打包成功了!!注:下载的依赖包会保存在~/.m2/repository文件夹中,打开这个文件夹,我们会发现里面的包正是按前面所说的四元组目录结构进行存储的。Maven在依赖一个jar包时会先去本地库查找,如果没找到就会从网上下载。当然,并不是所有的包都能从网上下载到,比如我们自己开发的jar包,这时,我们就可以用mvn install命令将一个项目安装到本地仓库。打包成功后我们会发现项目中多了一个target文件夹,目录结构如下#tree&helloworld/
helloworld/
├──&pom.xml
├──&src
│&&&├──&main
│&&&│&&&└──&java
│&&&│&&&&&&&└──&helloworld
│&&&│&&&&&&&&&&&└──&App.java
│&&&└──&test
│&&&&&&&└──&java
│&&&&&&&&&&&└──&helloworld
│&&&&&&&&&&&&&&&└──&AppTest.java
└──&target
&&&&├──&classes
&&&&│&&&└──&helloworld
&&&&│&&&&&&&└──&App.class
&&&&├──&helloworld-1.0-SNAPSHOT.jar
&&&&├──&maven-archiver
&&&&│&&&└──&pom.properties
&&&&├──&maven-status
&&&&│&&&└──&maven-compiler-plugin
&&&&│&&&&&&&├──&compile
&&&&│&&&&&&&│&&&└──&default-compile
&&&&│&&&&&&&│&&&&&&&├──&createdFiles.lst
&&&&│&&&&&&&│&&&&&&&└──&inputFiles.lst
&&&&│&&&&&&&└──&testCompile
&&&&│&&&&&&&&&&&└──&default-testCompile
&&&&│&&&&&&&&&&&&&&&├──&createdFiles.lst
&&&&│&&&&&&&&&&&&&&&└──&inputFiles.lst
&&&&├──&surefire-reports
&&&&│&&&├──&helloworld.AppTest.txt
&&&&│&&&└──&TEST-helloworld.AppTest.xml
&&&&└──&test-classes
&&&&&&&&└──&helloworld
&&&&&&&&&&&&└──&AppTest.class
20&directories,&13&files可以看到,在package过程中,maven完成了编译、测试代码,生成测试报告,生成jar包等一系列工作。d、手动运行jar包查看结果#cd&/tmp
#java&-cp&/root/helloworld/target/helloworld-1.0-SNAPSHOT.jar&helloworld.App
Hello&World!e、Maven常用命令介绍:Maven的命令非常多,学习命令首先要了解Maven的生命周期。Maven首先会验证并处理引用资源,之后进行项目编译,如果没有声明跳过测试,也会编译测试代码并进行测试、以成测试报告。最后,Maven会将编译好的内容进行打包,用于发布。Maven命令与Maven的生命周期有着对应的关系,一个命令也经常会包含多个生命周期,比如mvn package会完成以上所有步骤。这里列举几个常用的命令:mvn&compile&&&&&编译项目
mvn&test&&&&&&&&编译运行单元测试
mvn&package&&&&&打包(jar&or&war)
mvn&install&&&&&将项目安装到本地仓库
mvn&clean&&&&&&&清空项目
mvn&eclipse:eclipse&&&&&生成eclipse工程Maven安装配置部分参考链接: 五、通过Jenkins平台,自动构建jar或者war格式的代码包1、首先测试拉取代码情况前面已经在Jenkins配置了一个test_app项目,现在测试构建的情况,选择项目名,如下:然后在弹出页面的左侧选择“立即构建”,会出现一个进度条,然后点进去,在弹出页面的左侧选择“Console Output”,会看到整个构建过程输出的log,太多了,不能完全贴出来,不过最后是构建失败了,如下图:根据错误信息初步判断是一些jar包没有下载成功或者不存在导致的,先放这里,待会再介绍如何解决这个问题。到Jenkins服务器查看,代码是否已经从git拉取到本机了#cd&/root/.jenkins/workspace&&&&##此时你会看到test_app目录已经存在了
#ll&test_app&&&&&&&&&&&&&&&&&&&&##代码也已经拉取到本地了
drwxr-xr-x&2&root&root&4096&Jun&21&20:58&build
-rw-r--r--&1&root&root&5922&Jun&21&20:58&pom.xml
drwxr-xr-x&3&root&root&4096&Jun&21&20:58&src2、解决第1步出现的问题这里涉及到了maven镜像中央仓库,如果安装好maven之后,没有设置中央仓库(注释掉的),所以无法获取到需要的jar包,就会报错了设置仓库地址的配置文件在maven的安装目录中,叫settings.xml
#cd&/usr/local/maven/conf
#cat&settings.xml&|&grep&url&-A&12&-B&12
&&&|&server&for&that&repository.
&&&mirrors&
&&&&&!--&mirror&&&&&&&##是注释掉的
&&&&&|&Specifies&a&repository&mirror&site&to&use&instead&of&a&given&repository.&The&repository&that
&&&&&|&this&mirror&serves&has&an&ID&that&matches&the&mirrorOf&element&of&this&mirror.&IDs&are&used
&&&&&|&for&inheritance&and&direct&lookup&purposes,&and&must&be&unique&across&the&set&of&mirrors.
&&&&&mirror&
&&&&&&&id&mirrorId&/id&
&&&&&&&mirrorOf&repositoryId&/mirrorOf&
&&&&&&&name&Human&Readable&Name&for&this&Mirror.&/name&
&&&&&&&url&&&&##而且此处的地址也是无法访问的&
&&&&&/mirror&&&
&&&&&--&&&&&&&
&&&/mirrors&
&&&!--&profiles那需要如何解决这个问题呢,有几种方式:第一种是使用互联网开放的仓库地址:a、网上看到的一个开放的仓库地址是国外google的,如下:&mirrors&
&&&&&mirror&
&&&&&&&id&google-maven-central&/id&
&&&&&&&name&Google&Maven&Central&/name&
&&&&&&&url&https://maven-central.&/url&
&&&&&&&mirrorOf&central&/mirrorOf&
&&&&&/mirror&
&&&/mirrors&于是决定测试一下,将settings.xml文件修改为如下:#cat&settings.xml
&?xml&version="1.0"&encoding="UTF-8"?&&&
&settings&xmlns="http://maven.apache.org/SETTINGS/1.0.0"&&&
&&&&&&&&&&xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&&&
&&&&&&&&&&xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0&http://maven.apache.org/xsd/settings-1.0.0.xsd"&&&
&&&&&&&&&&&&
&&&!--&&localRepository&D:\bisoft\tools\maven3\repository&/localRepository&&&--&
&&&pluginGroups&&&
&&&&&!--&&pluginGroup&org.mortbay.jetty&/pluginGroup&&&
&&&&&pluginGroup&org.codehaus.cargo&/pluginGroup&&&&--&
&&&/pluginGroups&
&&&proxies&&&
&&&/proxies&&&
&&&servers&&&
&&&&&server&&&
&&&&&&&&&id&releases&/id&&&
&&&&&&&&&username&deployment&/username&&&
&&&&&&&&&password&deployment&/password&&&
&&&&&/server&&&
&&&&&server&&&
&&&&&&&&&id&snapshots&/id&&&
&&&&&&&&&username&deployment&/username&&&
&&&&&&&&&password&deployment&/password&&&
&&&&&/server&&&&&
&&&/servers&&&
&&&mirrors&&&
&&&&&mirror&
&&&&&&&id&google-maven-central&/id&&&
&&&&&&&mirrorOf&central&/mirrorOf&&&
&&&&&&&url&https://maven-central.&/url&&&##改为google仓库
&&&&&/mirror&&
&&&/mirrors&&&
&&&profiles&&&&&
&&&&&profile&&&
&&&&&&&&&id&google-maven-central&/id&&&
&&&&&&&&&repositories&&&
&&&&&&&&&&&repository&&&
&&&&&&&&&&&&&id&google-maven-central&/id&&&
&&&&&&&&&&&&&name&google-maven-central&/name&&&
&&&&&&&&&&&&&url&https://maven-central.&/url&&&
&&&&&&&&&&&&&releases&&enabled&true&/enabled&&/releases&&&
&&&&&&&&&&&&&snapshots&&enabled&true&/enabled&&/snapshots&&&
&&&&&&&&&&&/repository&&&
&&&&&&&&&/repositories&&&
&&&&&&&&&pluginRepositories&&&
&&&&&&&&&&&pluginRepository&&&
&&&&&&&&&&&&&id&google-maven-central&/id&&&
&&&&&&&&&&&&&name&google-maven-central&/name&&&
&&&&&&&&&&&&&url&https://maven-central.&/url&&&
&&&&&&&&&&&&&releases&&enabled&true&/enabled&&/releases&&&
&&&&&&&&&&&&&snapshots&&enabled&true&/enabled&&/snapshots&&&
&&&&&&&&&&&/pluginRepository&&&
&&&&&&&&&/pluginRepositories&&&
&&&&&/profile&&&
&&&&/profiles&&&&&
&&&activeProfiles&&&
&&&&&activeProfile&google-maven-central&/activeProfile&&&
&&&/activeProfiles&&&
&/settings&&&
&/settings&然后测试构建项目,不过结果是失败的,原因大家估计已经知道了,在国内google是被墙的,所以无法获取一些jar包,错误提示如下:所以这种方式行不通,就放弃了!b、国内的一个开源中国的Maven镜像仓库地址,如下:&&mirrors&
&&&&&mirror&
&&&&&&&id&nexus-osc&/id&
&&&&&&&mirrorOf&*&/mirrorOf&
&&&&&&&name&Nexus&osc&/name&
&&&&&&&url&http://maven.oschina.net/content/groups/public/&/url&
&&&&&/mirror&
&&&/mirrors&经过测试也是不行的,网上说有时还可以,有时候不行,就是不稳定!此处参考链接: 第二种是自己构建中央仓库,自己调用,下一篇文章中再介绍。初学,不足之处请多多指出,谢谢!本文出自 “” 博客,转载请与作者联系!
了这篇文章
类别:未分类┆阅读(0)┆评论(0)

我要回帖

更多关于 皇冠足球比分网 的文章

 

随机推荐