public static void main(String[] args) { AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); ctx.register(ApplicationConfig.class); ctx.refresh(); System.out.println("version: " + SpringVersion.getVersion()); SpringUI ui = ctx.getBean(SpringUI.class); ui.init(); }
/** * Created with IntelliJ IDEA. User: luog Date: 25/11/13 Time: 1:40 PM To change this template use * File | Settings | File Templates. */ public enum Version { ; public static final String VALUE; static { VALUE = IO.readContentAsString( Version.class.getClassLoader().getResourceAsStream("spring-rythm-version")); } public static final String SPRING_VERSION = SpringVersion.getVersion(); }
private Set<Object> getSources(MergedContextConfiguration mergedConfig) { Set<Object> sources = new LinkedHashSet<Object>(); sources.addAll(Arrays.asList(mergedConfig.getClasses())); sources.addAll(Arrays.asList(mergedConfig.getLocations())); if (sources.isEmpty()) { throw new IllegalStateException( "No configuration classes or locations found in @SpringApplicationConfiguration. " + "For default configuration detection to work you need Spring 4.0.3 or better (found " + SpringVersion.getVersion() + ")."); } return sources; }
protected Map<String, Object> createPluginContextAttributes() { Map<String, Object> attributes = new HashMap<String, Object>(); String bootVersion = CrshAutoConfiguration.class.getPackage().getImplementationVersion(); if (bootVersion != null) { attributes.put("spring.boot.version", bootVersion); } attributes.put("spring.version", SpringVersion.getVersion()); if (this.beanFactory != null) { attributes.put("spring.beanfactory", this.beanFactory); } if (this.environment != null) { attributes.put("spring.environment", this.environment); } return attributes; }
public StepExecution execute() { Step step = (Step) new ClassPathXmlApplicationContext(configLocation).getBean(stepName, Step.class); ; logger.info("Spring Version: " + SpringVersion.getVersion()); try { step.execute(stepExecution); } catch (JobInterruptedException e) { stepExecution.getJobExecution().setStatus(BatchStatus.STOPPING); throw new UnexpectedJobExecutionException("TODO: this should result in a stop", e); } return stepExecution; }
/** Performs version checks */ private static void performVersionChecks() { // Check Spring Compatibility String springVersion = SpringVersion.getVersion(); String version = getVersion(); if (disableChecks(springVersion, version)) { return; } logger.info("You are running with Spring Security Core " + version); if (springVersion.compareTo(MIN_SPRING_VERSION) < 0) { logger.warn( "**** You are advised to use Spring " + MIN_SPRING_VERSION + " or later with this version. You are running: " + springVersion); } }
static { // TimeZone UTC = TimeZone.getTimeZone("UTC"); // TimeZone.setDefault(UTC); _log.info("TimeZone is using " + TimeZone.getDefault().getID()); _log.info("Hibernate is using " + Environment.VERSION + "!"); _log.info("Spring is using " + SpringVersion.getVersion() + "!"); StringBuilder sb = new StringBuilder("System enviroment variables:\n"); Map<String, String> env = System.getenv(); String key; for (Iterator<String> it = env.keySet().iterator(); it.hasNext(); ) { key = it.next(); sb.append(key).append(" = ").append(env.get(key)).append("\n"); } Properties props = System.getProperties(); sb.append("System property values:\n"); for (Iterator<Object> it = props.keySet().iterator(); it.hasNext(); ) { key = (String) it.next(); sb.append(key).append(" = ").append(props.get(key)).append("\n"); } // _log.info(sb.toString()); // System.out.println("测试中文信息!!"); // _log.info("测试中文信息!!"); loadSettings(); }
public void visitSysinfo() { Map<String, Object> keyValues = createLinkedHashMap(); // Webx info keyValues.put("Webx Version", WebxUtil.getWebxVersion()); keyValues.put("Spring Version", SpringVersion.getVersion()); keyValues.put("Running Mode", productionMode ? "Production Mode" : "Development Mode"); // Java info keyValues.put( "Java", ArrayUtil.arrayToMap( new Object[][] { // {"Vendor", SystemUtil.getJavaInfo().getVendor()}, // {"Version", SystemUtil.getJavaInfo().getVersion()}, // }, String.class, String.class)); keyValues.put( "Java Runtime", ArrayUtil.arrayToMap( new Object[][] { // {"Name", SystemUtil.getJavaRuntimeInfo().getName()}, // {"Version", SystemUtil.getJavaRuntimeInfo().getVersion()}, // {"Home", SystemUtil.getJavaRuntimeInfo().getHomeDir()}, // }, String.class, String.class)); keyValues.put( "Java Spec.", ArrayUtil.arrayToMap( new Object[][] { // {"Name", SystemUtil.getJavaSpecInfo().getName()}, // {"Vendor", SystemUtil.getJavaSpecInfo().getVendor()}, // {"Version", SystemUtil.getJavaSpecInfo().getVersion()}, // }, String.class, String.class)); keyValues.put( "JVM", ArrayUtil.arrayToMap( new Object[][] { // {"Name", SystemUtil.getJvmInfo().getName()}, // {"Vendor", SystemUtil.getJvmInfo().getVendor()}, // {"Version", SystemUtil.getJvmInfo().getVersion()}, // {"Info", SystemUtil.getJvmInfo().getInfo()}, // }, String.class, String.class)); keyValues.put( "JVM Spec.", ArrayUtil.arrayToMap( new Object[][] { // {"Name", SystemUtil.getJvmSpecInfo().getName()}, // {"Vendor", SystemUtil.getJvmSpecInfo().getVendor()}, // {"Version", SystemUtil.getJvmSpecInfo().getVersion()}, // }, String.class, String.class)); // OS info keyValues.put( "OS", String.format( "%s %s %s", SystemUtil.getOsInfo().getName(), SystemUtil.getOsInfo().getArch(), SystemUtil.getOsInfo().getVersion())); keyValues.put("File Encoding", SystemUtil.getOsInfo().getFileEncoding()); keyValues.put("Host Name", SystemUtil.getHostInfo().getName()); keyValues.put("Host Address", SystemUtil.getHostInfo().getAddress()); // IPs try { Map<String, List<String>> networkAddresses = createTreeMap(); for (Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); e.hasMoreElements(); ) { NetworkInterface networkInterface = e.nextElement(); String name = networkInterface.getDisplayName(); List<String> addresses = createLinkedList(); for (Enumeration<InetAddress> e2 = networkInterface.getInetAddresses(); e2.hasMoreElements(); ) { addresses.add(e2.nextElement().getHostAddress()); } networkAddresses.put(name, addresses); } keyValues.put("Server IPs", networkAddresses); } catch (Exception e) { keyValues.put("Server IPs", e.getMessage()); } // Memory Map<String, String> memory = createLinkedHashMap(); memory.put("Free", formatMemory(Runtime.getRuntime().freeMemory())); memory.put("Total", formatMemory(Runtime.getRuntime().totalMemory())); memory.put("Maximum", formatMemory(Runtime.getRuntime().maxMemory())); keyValues.put("Memory", memory); keyValuesComponent.visitTemplate(context, keyValues); }