1.首先部署的时候,jinkens打的包,他是没有第三方jar包依赖的,此时就需要我们进行设置且自动部署
1.得到jar包
<build>
<finalName>news-room-zuul</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>TvuccZuulApplication</mainClass>
<layout>ZIP</layout>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</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>-->
<!-- <outputDirectory>target/lib</outputDirectory>-->
<!-- <excludeTransitive>false</excludeTransitive>-->
<!-- <stripVersion>false</stripVersion>-->
<!-- <includeScope>runtime</includeScope>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <layout>ZIP</layout>-->
<!-- <includes>-->
<!-- <include>-->
<!-- <groupId>com.tvunetworks.center</groupId>-->
<!-- <artifactId>tvucc-common</artifactId>-->
<!-- </include>-->
<!-- </includes>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-resources-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <source>1.8</source>-->
<!-- <target>1.8</target>-->
<!-- <encoding>UTF-8</encoding>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-surefire-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <skip>true</skip>-->
<!-- </configuration>-->
<!-- </plugin>-->
</plugins>
</build>
- 没有注释的打包之后会一个jar包,此时我们修改后缀为zip,进行解压就会得到如下图的效果
- 注释的代码 ,是所有依赖都放在一个jar包,即使解压也是一个
- 注意你启动类的class位置
2. 脚本自动部署
ps -ef|grep -w 'news-room.jar'|grep -v grep | awk '{print $2}' | xargs kill -9
cd /home/program/commandcenterplus
rm -f news-room.jar
wget http://xxxxxxx:8080/jenkins/job/tvu-NewRoom/lastSuccessfulBuild/artifact/target/news-room.jar ## jenkins最终版本地址
nohup java -jar -Dloader.path="lib/news-room/" -Dspring.application.name=news-room -Xms256m -Xmx256m news-room.jar >/dev/null 2>&1 &
~
此时的我们只需要运行脚本即可