[英]Deploy Spring Boot war into Jenkins
I have a Jenkins
job for deploy Spring-Boot war. 我有一个Jenkins
工作,负责部署Spring-Boot战争。
When I launch my job I have this error: 当我开始工作时,出现以下错误:
[INFO] --- maven-war-plugin:2.5:war (default-war) @ rest-api ---
[INFO] Packaging webapp
[INFO] Assembling webapp [rest-api] in [/var/lib/jenkins/jobs/BOAOBJ/workspace/target/rest-api-1.0.0]
[INFO] Processing war project
[INFO] Webapp assembled in [459 msecs]
[INFO] Building war: /var/lib/jenkins/jobs/BOAOBJ/workspace/target/rest-api-1.0.0.war
[INFO]
[INFO] --- spring-boot-maven-plugin:1.3.0.RC1:repackage (default) @ rest-api ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.040 s
[INFO] Finished at: 2016-04-22T14:04:30+02:00
[INFO] Final Memory: 29M/245M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.3.0.RC1:repackage (default) on project rest-api: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.3.0.RC1:repackage failed: Unable to find main class -> [Help 1]
[ERROR]
[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]
Pom.xml: Pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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>com.Lyreco.lab</groupId>
<artifactId>rest-api</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.0.RC1</version>
</parent>
<properties>
<springfox-version>2.2.2</springfox-version>
<java.version>1.7</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<exclusions>
<exclusion>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-server</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>3.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>3.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId>
<version>0.19.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>hal-browser</artifactId>
<version>9f96c74</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.6.0</version>
</dependency>
<!-- Swagger 2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox-version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${springfox-version}</version>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>4.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>${project.parent.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>repository.springsource.milestone</id>
<name>SpringSource Milestone Repository</name>
<url>http://repo.springsource.org/milestone</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>repository.springsource.milestone</id>
<name>SpringSource Milestone Repository</name>
<url>http://repo.springsource.org/milestone</url>
</pluginRepository>
</pluginRepositories>
</project>
Why ? 为什么呢
[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.3.0.RC1:repackage (default) on project rest-api:
Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.3.0.RC1:repackage failed: **Unable to find main class** -> [Help 1]
The spring-boot-maven-plugin allows you to package executable jar or war archives and run an application(automatically). spring-boot-maven-plugin允许您打包可执行的jar或war归档文件并自动运行应用程序。 So, you will need specify the Main class for your application. 因此,您将需要为应用程序指定Main类。 See guideline here. 请参阅此处的指南 。
So, in short, you can add main class to your Manifest by: 因此,简而言之,您可以通过以下方式将主类添加到清单中:
Add directly to Manifest.MF 直接添加到Manifest.MF
Specify Optional Parameters for spring-boot-maven-plugin in your pom.xml. 在pom.xml中为spring-boot-maven-plugin指定可选参数 。 Below is example: 下面是示例:
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>1.0.3.BUILD-SNAPSHOT</version> <configuration> <mainClass>com.test.Application</mainClass> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.