这是在运行时获取Java应用程序的当前工作目录的代码.
String currentWorkingDirectory = System.getProperty("user.dir")+System.getProperty("file.separator");
Run Code Online (Sandbox Code Playgroud)
有没有办法使用spring-context xml配置它.
例如:
<bean id="csvReportGenerator" class="some.path.CSVReportGenerator">
<constructor-arg name="outputFileName" value="${currentWorkingDirectory}/${reportOutputFileGeneric}"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
是的,你可以使用Spring表达式来完成它.见第6.4.1 本文章
<property name="userDir" value="#{ systemProperties['user.dir'] }"/>
<property name="fileSep" value="#{ systemProperties['file.separator'] }"/>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7548 次 |
| 最近记录: |