CentOS7安装Jenkins2.7.x并部署服务
先导入仓库
wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins.io/redhat-stable/jenkins.repo
rpm --import http://pkg.jenkins.io/redhat-stable/jenkins.io.key安装
yum install jenkins
<build>web:
<defaultGoal>compile</defaultGoal>
<resources>
<resource>
<targetPath>${project.build.directory}/classes</targetPath>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.4.2</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<!-- 打包jar文件时,配置manifest文件,加入lib包的jar依赖 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<classesDirectory>target/classes/</classesDirectory>
<archive>
<manifest>
<!--实际为调用com.alibaba.dubbo.container.Main-->
<mainClass>Main</mainClass>
<!-- 打包时 MANIFEST.MF文件不记录的时间戳版本 -->
<useUniqueVersions>false</useUniqueVersions>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
</manifest>
<manifestEntries>
<Class-Path>.</Class-Path>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<type>jar</type>
<includeTypes>jar</includeTypes>
<!--<useUniqueVersions>false</useUniqueVersions>-->
<outputDirectory>
${project.build.directory}/lib
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<build>
<finalName>web-demo</finalName>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<port>9090</port>
<uriEncoding>UTF-8</uriEncoding>
<url>http://127.0.0.1:9090/manager/text</url>
<!--在maven的settings.xml中有配置的-->
<server>tomcat8</server>
<path>/web-demo</path>
</configuration>
</plugin>
</plugins>
</build>
五、部署WEB服务2
如果使用jetty插件,则简单很多,运行命令为:clean compile jetty:run。
以下为插件配置:
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.3.12.v20160915</version>
<configuration>
<!-- 指定监控的扫描时间间隔,0为关闭jetty自身的热部署,主要是为了使用jrebel -->
<scanIntervalSeconds>0</scanIntervalSeconds>
<httpConnector>
<port>9090</port>
</httpConnector>
<webApp>
<contextPath>/</contextPath>
</webApp>
<!-- 指定额外需要监控变化的文件或文件夹,主要用于热部署中的识别文件更新 -->
<scanTargetPatterns>
<scanTargetPattern>
<directory>src</directory>
<includes>
<include>**/*.java</include>
<include>**/*.properties</include>
</includes>
<!-- <excludes> <exclude>**/*.xml</exclude> <exclude>**/myspecial.properties</exclude> </excludes> -->
</scanTargetPattern>
</scanTargetPatterns>
<webAppSourceDirectory>${basedir}/src/main/webapp</webAppSourceDirectory>
</configuration>
</plugin>