@RequestMapping(value = "/", method = GET) public String home(Model model) { String springVersion = webUI.parameterizedMessage("home.spring.version", SpringBootVersion.getVersion()); model.addAttribute("springVersion", springVersion); GitHubStats gitHubStats = webUI.getCurrentGitHubStats(); if (gitHubStats != null) { model.addAttribute("showGitHubStats", true); model.addAttribute("gitHubStats", gitHubStats); } if (webUI.isNixMash()) { SiteImage siteImage = siteService.getHomeBanner(); model.addAttribute("siteImage", siteImage); } Slice<Post> posts = postService.getPublishedPosts(0, 10); if (posts.getContent().size() > 0) model.addAttribute("posts", posts); return HOME_VIEW; }
@Override public void initialize(TelemetryContext telemetryContext) { RelaxedPropertyResolver relaxedPropertyResolver = new RelaxedPropertyResolver(environment); telemetryContext.getTags().put("ai.spring-boot.version", SpringBootVersion.getVersion()); telemetryContext.getTags().put("ai.spring.version", SpringVersion.getVersion()); String ipAddress = relaxedPropertyResolver.getProperty("spring.cloud.client.ipAddress"); if (ipAddress != null) { // if spring-cloud is available we can set ip address telemetryContext.getTags().put(ContextTagKeys.getKeys().getLocationIP(), ipAddress); } }
/** * Collect environment info with * details on the java and os deployment * versions. * * @param environment the environment * @param sourceClass the source class * @return environment info */ private String collectEnvironmentInfo(final Environment environment, final Class<?> sourceClass) { final Properties properties = System.getProperties(); if (properties.containsKey("CAS_BANNER_SKIP")) { try (Formatter formatter = new Formatter()) { formatter.format("CAS Version: %s%n", CasVersion.getVersion()); return formatter.toString(); } } try (Formatter formatter = new Formatter()) { formatter.format("CAS Version: %s%n", CasVersion.getVersion()); formatter.format("CAS Commit Id: %s%n", CasVersion.getSpecificationVersion()); formatter.format("CAS Build Date/Time: %s%n", CasVersion.getDateTime()); formatter.format("Spring Boot Version: %s%n", SpringBootVersion.getVersion()); formatter.format("%s%n", LINE_SEPARATOR); formatter.format("System Date/Time: %s%n", LocalDateTime.now()); formatter.format("System Temp Directory: %s%n", FileUtils.getTempDirectoryPath()); 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")); formatter.format("JCE Installed: %s%n", 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("%s%n", LINE_SEPARATOR); injectEnvironmentInfoIntoBanner(formatter, environment, sourceClass); return formatter.toString(); } }
public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(ApplicationConfig.class); ctx.refresh(); System.out.println("Spring Framework Version: " + SpringVersion.getVersion()); System.out.println("Spring Boot Version: " + SpringBootVersion.getVersion()); JpaUI ui = ctx.getBean(JpaUI.class); ui.init(); ctx.close(); }
@RequestMapping(value = "/dev/banner", method = GET) public String homeBannerDisplay(Model model, @RequestParam(value = "id") long siteImageId) { String springVersion = webUI.parameterizedMessage("home.spring.version", SpringBootVersion.getVersion()); model.addAttribute("springVersion", springVersion); SiteImage siteImage = siteService.getHomeBanner(siteImageId); model.addAttribute("siteImage", siteImage); Slice<Post> posts = postService.getPublishedPosts(0, 10); if (posts.getContent().size() > 0) model.addAttribute("posts", posts); return HOME_VIEW; }
@GetMapping public String getHome(Model model) { model.addAttribute("sbVersion", SpringBootVersion.getVersion()); return "home"; }
/** * Contribute SpringBoot version to "/info". * * @return {@link InfoContributor} */ @Bean public InfoContributor versionInfo() { return builder -> builder.withDetail("spring-boot.version", SpringBootVersion.getVersion()); }