类org.springframework.boot.SpringBootVersion源码实例Demo

下面列出了怎么用org.springframework.boot.SpringBootVersion的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: sofa-ark   文件: OnSpringBootVersion.java
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
    Map<String, Object> springBootVersion = metadata
        .getAnnotationAttributes(ConditionalOnSpringBootVersion.class.getCanonicalName());
    if (springBootVersion == null || springBootVersion.get("version") == null) {
        return new ConditionOutcome(false, "No specified spring boot version.");
    }
    ConditionalOnSpringBootVersion.Version version = (ConditionalOnSpringBootVersion.Version) springBootVersion
        .get("version");
    if (ConditionalOnSpringBootVersion.Version.ANY.equals(version)) {
        return new ConditionOutcome(true, "Conditional on Any Spring Boot.");
    } else if (ConditionalOnSpringBootVersion.Version.OneX.equals(version)) {
        if (SpringBootVersion.getVersion().startsWith("1")) {
            return new ConditionOutcome(true, "Conditional on OneX Spring Boot.");
        } else {
            return new ConditionOutcome(false, "Conditional on OneX Spring Boot.");
        }
    } else if (ConditionalOnSpringBootVersion.Version.TwoX.equals(version)) {
        if (SpringBootVersion.getVersion().startsWith("2")) {
            return new ConditionOutcome(true, "Conditional on TwoX Spring Boot.");
        } else {
            return new ConditionOutcome(false, "Conditional on TwoX Spring Boot.");
        }
    }
    throw new IllegalStateException("Error Spring Boot Version.");
}
 
源代码2 项目: oneplatform   文件: SpringBootBanner.java
@Override
public void printBanner(Environment environment, Class<?> sourceClass,
		PrintStream printStream) {
	for (String line : BANNER) {
		printStream.println(line);
	}
	String version = SpringBootVersion.getVersion();
	version = (version == null ? "" : " (v" + version + ")");
	String padding = "";
	while (padding.length() < STRAP_LINE_SIZE
			- (version.length() + SPRING_BOOT.length())) {
		padding += " ";
	}

	printStream.println(AnsiOutput.toString(AnsiColor.GREEN, SPRING_BOOT,
			AnsiColor.DEFAULT, padding, AnsiStyle.FAINT, version));
	printStream.println();
}
 
/**
 * When there are no `ClientFactory`s with `ForCentralDogma` qualifier,
 * the default `ClientFactory` must be used.
 */
@Test
void centralDogmaClient() throws Exception {
    assertThat(client).isNotNull();

    if (SpringBootVersion.getVersion().startsWith("1.")) {
        // JUnit 5 extension for Spring Boot 1.x has a bug which pulls in a bean from other tests,
        // so we can't test this properly.
        final ClientFactory expectedClientFactory =
                new CentralDogmaClientAutoConfigurationWithClientFactoryTest.TestConfiguration()
                        .dogmaClientFactory();
        assertThat(clientFactory).isSameAs(expectedClientFactory);
    } else {
        assertThat(clientFactory).isSameAs(ClientFactory.ofDefault());
    }
}
 
源代码4 项目: Moss   文件: Analyzer.java
public static JarDependencies getAllPomInfo() throws Exception {
    JarDependencies jarDependencies = new JarDependencies();
    List<PomInfo> pomInfos = getAllJarPomInfo();
    jarDependencies.setPomInfos(pomInfos);
    jarDependencies.setSpringBootVersion(SpringBootVersion.getVersion());
    Optional<PomInfo> optionalPomInfo = pomInfos.stream().filter( //
        x -> (StringUtils.isNotEmpty(x.groupId) && x.groupId.equals("org.springframework.cloud")
                &&x.artifactId.equals("spring-cloud-commons")))
        .findFirst();
    setSpringCloudDeps(optionalPomInfo, jarDependencies);

    return jarDependencies;
}
 
源代码5 项目: jbone   文件: AbastractJboneBanner.java
/**
 * 收集环境信息,包括Java、操作系统等
 *
 * @param environment 当前运行环境
 * @param sourceClass 启动类
 * @return 环境信息
 */
private String collectEnvironmentInfo(final Environment environment, final Class<?> sourceClass) {
    final Properties properties = System.getProperties();

    try (Formatter formatter = new Formatter()) {
        formatter.format("Spring Boot Version: %s%n", SpringBootVersion.getVersion());
        formatter.format("%s%n", LINE_SEPARATOR);

        formatter.format("Java Home: %s%n", properties.get("java.home"));
        formatter.format("Java Vendor: %s%n", properties.get("java.vendor"));
        formatter.format("Java Version: %s%n", properties.get("java.version"));
        final Runtime runtime = Runtime.getRuntime();
        formatter.format("JVM Free Memory: %s%n", FileUtils.byteCountToDisplaySize(runtime.freeMemory()));
        formatter.format("JVM Maximum Memory: %s%n", FileUtils.byteCountToDisplaySize(runtime.maxMemory()));
        formatter.format("JVM Total Memory: %s%n", FileUtils.byteCountToDisplaySize(runtime.totalMemory()));
        formatter.format("JCE Installed: %s%n", StringUtils.capitalize(BooleanUtils.toStringYesNo(isJceInstalled())));
        formatter.format("%s%n", LINE_SEPARATOR);

        formatter.format("OS Architecture: %s%n", properties.get("os.arch"));
        formatter.format("OS Name: %s%n", properties.get("os.name"));
        formatter.format("OS Version: %s%n", properties.get("os.version"));
        formatter.format("OS Date/Time: %s%n", LocalDateTime.now());
        formatter.format("OS Temp Directory: %s%n", FileUtils.getTempDirectoryPath());

        formatter.format("%s%n", LINE_SEPARATOR);


        injectEnvironmentInfoIntoBanner(formatter, environment, sourceClass);

        return formatter.toString();
    }
}
 
@Test
public void partialEncodedParameters() {
	assumeTrue("partialEncodedParameters ignored for boot 2.2",
			SpringBootVersion.getVersion().startsWith("2.3."));

	URI url = UriComponentsBuilder
			.fromUriString("http://localhost/get?key[]=test= key&start=1533108081")
			.build().toUri();

	// prove that it is partial encoded
	assertThat(url.getRawQuery()).isEqualTo("key[]=test=%20key&start=1533108081");

	assertThat(url).hasParameter("key[]", "test= key");
	assertThat(url).hasParameter("start", "1533108081");

	MockServerHttpRequest request = MockServerHttpRequest.method(HttpMethod.GET, url)
			.build();

	ServerWebExchange webExchange = testFilter(request, "http://myhost");
	URI uri = webExchange.getRequiredAttribute(GATEWAY_REQUEST_URL_ATTR);
	assertThat(uri).hasScheme("http").hasHost("myhost")
			// since https://github.com/joel-costigliola/assertj-core/issues/1699
			// assertj uses raw query
			.hasParameter("key[]", "test=%20key").hasParameter("start", "1533108081");

	// prove that it is double encoded since partial encoded uri is treated as
	// unencoded.
	assertThat(uri.getRawQuery()).isEqualTo("key[]=test=%2520key&start=1533108081");
}
 
protected String getLiquibaseProperty() {
    String springBootVersion = SpringBootVersion.getVersion();
    if (springBootVersion == null || !springBootVersion.startsWith("1")) {
        return "spring.liquibase.enabled";
    } else {
        return "liquibase.enabled";
    }
}
 
private static boolean thatSupportForNestedPropertiesIsAvailable() {

		Version minVersion = Version.parse("2.0.5");

		return Optional.ofNullable(SpringBootVersion.getVersion()).map(Version::parse) //
				.map(v -> v.isGreaterThanOrEqualTo(minVersion)) //
				.orElseGet(ActorRepositoryIntegrationTest::fallBackToVersionSpecificClasses);
	}
 
@Test
public void verifierPropertiesContainsCurrentBootVersion() {
	String version = SpringBootVersion.getVersion();
	assertThat(version).isNotBlank();

	for (String compatibleVersion : verifierProperties.getCompatibleBootVersions()) {
		if (version.startsWith(stripWildCardFromVersion(compatibleVersion))) {
			// success we found the current boot version in our list of compatible
			// versions.
			return;
		}
	}
	fail(version + " not found in " + verifierProperties.getCompatibleBootVersions());
}
 
源代码10 项目: bugsnag-java   文件: SpringMvcTest.java
@Test
@SuppressWarnings("unchecked")
public void springVersionSetCorrectly() {
    callRuntimeExceptionEndpoint();

    Report report = verifyAndGetReport(delivery);

    // Check that the Spring version is set as expected
    Map<String, Object> deviceMetadata = report.getDevice();
    Map<String, Object> runtimeVersions =
            (Map<String, Object>) deviceMetadata.get("runtimeVersions");
    assertEquals(SpringVersion.getVersion(), runtimeVersions.get("springFramework"));
    assertEquals(SpringBootVersion.getVersion(), runtimeVersions.get("springBoot"));
}
 
源代码11 项目: Moss   文件: AdminEndPointConfiguration.java
@Bean
public SimpleInfoContributor springBootVersionInfoContributor() {
    return new SimpleInfoContributor("spring-boot-version", SpringBootVersion.getVersion());
}
 
源代码12 项目: sofa-ark   文件: ArkApplicationStartListener.java
public boolean isSpringBoot1() {
    return SpringBootVersion.getVersion().startsWith("1");
}
 
源代码13 项目: sofa-ark   文件: ArkApplicationStartListener.java
public boolean isSpringBoot2() {
    return SpringBootVersion.getVersion().startsWith("2");
}
 
源代码14 项目: RuoYi   文件: RuoYiApplication.java
public static void main(String[] args) {
    Instant inst1 = Instant.now();
    SpringApplication.run(RuoYiApplication.class, args);
    log.info(":: 若依管理系统Java开发平台  :: 基于 Spring Boot {} ::", SpringBootVersion.getVersion());
    log.info(":: 启动成功!耗时:{}秒 ::", Duration.between(inst1, Instant.now()).getSeconds());
}
 
@Override
public String getVersion() {
	return "1.0 on Spring Boot " + SpringBootVersion.getVersion();
}
 
String getVersionFromManifest() {
	return SpringBootVersion.getVersion();
}
 
源代码17 项目: bugsnag-java   文件: SpringBootConfiguration.java
private void addSpringRuntimeVersion(Map<String, Object> device) {
    Diagnostics.addDeviceRuntimeVersion(device, "springBoot", SpringBootVersion.getVersion());
}
 
源代码18 项目: secrets-proxy   文件: MgmtConfig.java
/**
 * Contribute SpringBoot version to "/info".
 *
 * @return {@link InfoContributor}
 */
@Bean
public InfoContributor versionInfo() {
  return builder -> builder.withDetail("spring-boot.version", SpringBootVersion.getVersion());
}
 
 类所在包
 类方法
 同包方法