`
liusu
  • 浏览: 170029 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Spring读取系统属性的方法就是先读system.getProperty() 然后再读 System.getenv()

 
阅读更多
这是整个调用的Stacktrace


Thread [main] (Suspended)	
	owns: Object  (id=22)	
	PropertyPlaceholderConfigurer.resolveSystemProperty(String) line: 358	
	PropertyPlaceholderConfigurer.resolvePlaceholder(String, Properties, int) line: 324	
	PropertyPlaceholderConfigurer$PropertyPlaceholderConfigurerResolver.resolvePlaceholder(String) line: 418	
	PropertyPlaceholderHelper.parseStringValue(String, PlaceholderResolver, Set<String>) line: 146	
	PropertyPlaceholderHelper.replacePlaceholders(String, PropertyPlaceholderHelper$PlaceholderResolver) line: 125	
	PropertyPlaceholderConfigurer$PlaceholderResolvingStringValueResolver.resolveStringValue(String) line: 403	
	BeanDefinitionVisitor.resolveStringValue(String) line: 281	
	BeanDefinitionVisitor.resolveValue(Object) line: 202	
	BeanDefinitionVisitor.visitPropertyValues(MutablePropertyValues) line: 140	
	BeanDefinitionVisitor.visitBeanDefinition(BeanDefinition) line: 81	
	PropertyPlaceholderConfigurer.processProperties(ConfigurableListableBeanFactory, Properties) line: 284	
	PropertyPlaceholderConfigurer(PropertyResourceConfigurer).postProcessBeanFactory(ConfigurableListableBeanFactory) line: 75	
	FileSystemXmlApplicationContext(AbstractApplicationContext).invokeBeanFactoryPostProcessors(Collection<BeanFactoryPostProcessor>, ConfigurableListableBeanFactory) line: 663	
	FileSystemXmlApplicationContext(AbstractApplicationContext).invokeBeanFactoryPostProcessors(ConfigurableListableBeanFactory) line: 638	
	FileSystemXmlApplicationContext(AbstractApplicationContext).refresh() line: 407	
	FileSystemXmlApplicationContext.<init>(String[], boolean, ApplicationContext) line: 140	
	FileSystemXmlApplicationContext.<init>(String) line: 84	
	Main.main(String[]) line: 14	
	



这是方法内部, 一清二楚啊。。
	/**
	 * Resolve the given key as JVM system property, and optionally also as
	 * system environment variable if no matching system property has been found.
	 * @param key the placeholder to resolve as system property key
	 * @return the system property value, or <code>null</code> if not found
	 * @see #setSearchSystemEnvironment
	 * @see java.lang.System#getProperty(String)
	 * @see java.lang.System#getenv(String)
	 */
	protected String resolveSystemProperty(String key) {
		try {
			String value = System.getProperty(key);
			if (value == null && this.searchSystemEnvironment) {
				value = System.getenv(key);
			}
			return value;
		}
		catch (Throwable ex) {
			if (logger.isDebugEnabled()) {
				logger.debug("Could not access system property '" + key + "': " + ex);
			}
			return null;
		}
	}
分享到:
评论

相关推荐

    Java中System.getProperty的使用

    Java中System.getProperty的使用

    使用System.getProperty(line.separator).md

    这是本人在进行使用递归替换HTML文件中的图片内容时,所遇到的问题解决方案,喜欢能够帮到大家,让自己懂得东西越来愈多,做更多的分享

    System.getProperty

    System.getProperty 通过该方法获取系统属性信息 很好

    Java的System.getProperty()方法获取大全

    主要介绍了Java的System.getProperty()方法获取大全,罗列了System.getProperty()方法获取各类信息的用法,具有一定的参考借鉴价值,需要的朋友可以参考下

    JAVA获取操作系统名称

    java获取操作系统名称,通过 System.getProperty("os.name") 由于JDK的bug,Windows Server 2012 R2获取到的System.getProperty("os.name") 为 Window NT unknown 因此需要通过JNA(Java Native Access )调用...

    intellij idea 设置多module路径.docx

    intellij idea 多module时,System.getProperty("user.dir")获取的是默认路径。此文档修改获取到的module路径。使获取的路径到当前module实际路径。亲测好用

    java log4j统一打印在user.dir目录下(windows、linux通用、不用考虑不同操作系统分隔符不一致的情况)

    java log4j统一打印在user.dir目录下(windows、linux通用、不用考虑不同操作系统分隔符不一致的情况)

    java反射配置文件实现

    用反射原理 从配置文件中读取数据 public static void main(String[] args) throws Exception{ Properties pro=new Properties(); pro.load(new FileInputStream("fanshe.txt")); //Class c=null; String ...

    BlackBerry系统属性

    使用 System.getProperty(“property_name”)来获取属性值,以下是BlackBerry9700 的 值: 1. microedition.encoding 属性:代表手机默认的字符集名称 返回值:“ISO-8859-1” 2. microedition.configuration ...

    Java连接数据库代码

    Java连接数据库代码实现代码, 代码片段: public MyTask(ServletContext context) { this.mContext = context; Properties prop = new Properties();... System.out.println("sql ip: "+this.sql_ip);

    java jar包附带的doc.jar包文件 查看器 api 图形界面

    本地离线查看类似fastjson-1.2.21-javadoc.jar这样的doc文件,原理其实也是java读取该压缩文件,解压到System.getProperty("java.io.tmpdir")/javadoc-viewer下,再调用浏览器打开里面的index.html文件。 每次可以...

    查看系统属性java小工具

    作用:列出当前系统所有的属性及对应属性值。 使用方法:在当前文件路径运行“java -jar showsystemproperties.jar”。 使用场景:忘记了System.getProperty(String key)中的属性名等。

    jxl 生成报表 读取报表

    String template=System.getProperty("user.dir")+"\\src\\template.xls";//模板文件 String book=System.getProperty("user.dir")+"\\src\\book.xls"; Workbook wb=Workbook.getWorkbook(new File(template))...

    JFreeChart双Y轴折线图实例,可以直接运行

    System.out.println(System.getProperty("java.io.tmpdir")); System.out.println(filename); %&gt; &lt;img src="&lt;%= graphURL %&gt;" width="600" height="400" border="0" usemap="#&lt;%= filename %&gt;"&gt; 记得在每次调用...

    JAVA获取项目路径.doc

    利用System.getProperty()函数获取当前路径: System.out.println(System.getProperty("user.dir"));//user.dir指定了当前的路径

    jacob.jar1.19及使用方法

    jacob.jar1.19及使用方法 解压后获得3个文件 jacob.jar jacob-1.17-x64.dll jacob-1.17-x86.dll jacob.jar 放到项目的lib目录 win7 jacob-1.17-x64.dll 放到C:\Windows\System32 jacob-1.17-x86.dll 放到C:\...

    ueditor-1.4.3_utf8_修正版本(解决windows下在线图库及上传图问题)

    请注意:加入百度ueditor插件的项目或产品,在linux下部署无问题,只要部署好就可以,但是如果是windows系统的话,上传... //System.out.println("操作系统类型&gt;&gt;&gt;&gt;"+System.getProperty("os.name")); return str; }

    java屏幕录像(包含鼠标轨迹)生成avi媒体文件

    new File(System.getProperty("user.home")+File.separator+"Videos"); 其它: new File(System.getProperty("user.home")+File.separator+"Movies"); 我的电脑是C:\Documents and Settings\hz001\Videos这个路径 ...

    利用jacob将office转换成html

    1.将jacob.jar导入到项目的lib中去 2.将Jacob.dll放至“WINDOWS\SYSTEM32”下面(或者放在对应的jdk目录下 如:C:\Program ...附:可以通过System.out.println(System.getProperty("java.library.path"))查出jdk的信息

    服务器监控架构模型

    获取服务器的参数和属性资源,简单的使用了J2EE架构进行B/S结构的部署。 示例: // a)取硬盘已有的分区及其详细信息(通过sigar.getFileSystemList()来获得FileSystem列表对象,然后对其进行编历): public void ...

Global site tag (gtag.js) - Google Analytics