附录

遇到 Spring Cloud Skipper 问题,我们想帮忙!spring-doc.cn

附录 A:架构

要构建源代码,您需要安装 JDK 1.8。spring-doc.cn

该版本使用 Maven 包装器,因此您不必安装特定版本的 Maven。spring-doc.cn

主要的构建命令是spring-doc.cn

$ ./mvnw clean install

要创建可执行文件并避免运行测试和生成 JavaDocs,请使用以下命令:spring-doc.cn

$ ./mvnw clean package -DskipTests -Dmaven.javadoc.skip=true
您也可以自己安装 Maven (>=3.3.3) 并运行命令来代替示例中的 。 如果这样做,则如果本地 Maven 设置不包含 Spring 预发布工件的存储库声明,则可能还需要添加。mvn./mvnw-P spring
您可能需要通过设置具有类似 . 我们尝试在配置中涵盖这一点,因此,如果您发现必须增加内存才能使构建成功,请提交票证以将设置添加到源代码控制中。MAVEN_OPTS-Xmx512m -XX:MaxPermSize=128m.mvn

A.1. 文档

要仅生成 REST 文档,请使用以下命令:spring-doc.cn

$ ./mvnw test -pl spring-cloud-skipper-server-core -Dtest=*Documentation*

要构建唯一的 Asciidoctor 文档,请使用以下命令:spring-doc.cn

$ ./mvnw package -DskipTests -Pfull -pl spring-cloud-skipper-docs

A.2. 自定义服务器构建

本章包含如何创建自定义服务器的说明 build 并应该导致与 一个来自 Skipper 构建本身。spring-doc.cn

它需要遵循 Skipper 本身使用的相同 Spring Boot 主类结构。 示例如下所示:spring-doc.cn

package com.example.customskipperserver;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.session.SessionAutoConfiguration;
import org.springframework.cloud.deployer.spi.cloudfoundry.CloudFoundryDeployerAutoConfiguration;
import org.springframework.cloud.deployer.spi.kubernetes.KubernetesAutoConfiguration;
import org.springframework.cloud.deployer.spi.local.LocalDeployerAutoConfiguration;
import org.springframework.cloud.skipper.server.EnableSkipperServer;

@SpringBootApplication(exclude = {
                CloudFoundryDeployerAutoConfiguration.class,
                KubernetesAutoConfiguration.class,
                LocalDeployerAutoConfiguration.class,
                ManagementWebSecurityAutoConfiguration.class,
                SecurityAutoConfiguration.class,
                SessionAutoConfiguration.class
        })
@EnableSkipperServer
public class CustomSkipperServerApplication {

	public static void main(String[] args) {
		SpringApplication.run(CustomSkipperServerApplication.class, args);
	}
}

Maven 的工作构建文件如下所示:spring-doc.cn

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>

	<groupId>com.example</groupId>
	<artifactId>custom-skipper-server</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<packaging>jar</packaging>

	<name>custom-skipper-server</name>
	<description>Demo project for Spring Boot</description>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.7.18</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<java.version>1.8</java.version>
		<spring-cloud.version>2021.0.9</spring-cloud.version>
		<spring-cloud-skipper.version>2.11.5</spring-cloud-skipper.version>
		<!--
			reactor and flyway are managed by boot so this is an illustration of how to modify the versions since
			trying to import boms in dependencyManagement would not actually change versions.
		-->
		<reactor.version>3.0.7.RELEASE</reactor.version>
		<flyway.version>5.0.5</flyway.version>
	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-skipper-server</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-dependencies</artifactId>
				<version>${spring-cloud.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
			<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-skipper-dependencies</artifactId>
				<version>${spring-cloud-skipper.version}</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>


	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>
</project>

Gradle 的工作构建文件如下所示:spring-doc.cn

buildscript {
	ext {
		springBootVersion = '2.7.18'
	}
	repositories {
		mavenCentral()
	}
	dependencies {
		classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
	}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
	mavenLocal()
	mavenCentral()
	maven { url "https://repo.springsource.org/libs-snapshot" }
	maven { url "https://repo.springsource.org/libs-release" }
	maven { url "https://repo.springsource.org/libs-milestone" }
}


ext {
	springCloudVersion = '2021.0.9'
	springCloudSkipperVersion = '2.11.5'
	reactorVersion = 'Aluminium-SR3'
	reactorNettyVersion = '0.6.6.RELEASE'
	objenesisVersion = '2.1'
}

dependencies {
	compile('org.springframework.cloud:spring-cloud-starter-skipper-server')
	testCompile('org.springframework.boot:spring-boot-starter-test')
}

dependencyManagement {
	imports {
		mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
		mavenBom "org.springframework.cloud:spring-cloud-skipper-dependencies:${springCloudSkipperVersion}"
		mavenBom "io.projectreactor:reactor-bom:${reactorVersion}"
	}
	dependencies {
		// latest reactor bom is still using reactor-netty:0.6.3.RELEASE
		// so we need to change it here because cf java client use
		// dedicated netty version while they should have been using
		// reactor boms assuming reactor boms would be up-to-date
		dependency "io.projectreactor.ipc:reactor-netty:${reactorNettyVersion}"
		// this is unfortunate mess with objenesis as there's versions 2.1 and 2.6
		// in build path and nobody manages version and maven vs. gradle is different
		dependency "org.objenesis:objenesis:${objenesisVersion}"
	}
}

A.3. 导入到 eclipse 中

您可以使用以下命令生成 Eclipse 项目元数据:spring-doc.cn

$ ./mvnw eclipse:eclipse

在 Eclipse 中,可以通过从菜单中选择来导入生成的项目。Import existing projectsFilespring-doc.cn