英文:
Not able to switch current directory from one spring project to another
问题
我有一个应用程序,有两个不同的组件。一个是核心(组件 A),另一个组件包含所有文件资源(组件 B)。当我运行应用程序时,组件 A 被运行并从另一个组件 B 获取如 xml、xslt、xsd 等文件。我们最近升级到了最新版本的 Spring 5 和 Open JDK 11。在版本升级后,当运行组件 A 的 JUnit 测试时,我遇到了文件未找到的异常。尽管我们将 user.dir 设置为切换到当前目录,但它仍然试图在 A 的文件夹结构中进行检查。
使用以下代码:
System.setProperty("user.dir", systemUserDir + "/../ComponentB/src/main/resources");
然后我们在属性文件中有一个属性,我们将其附加到上面的路径中:
TEST.Test.XSLTFile=document/business/Test.xslt
所以理应在 ComponentB 的路径中搜索,但它却尝试在 Component A 的路径中搜索文件。
英文:
I have an application with two different components. One is core (component A) and other has all file resources (component B). When I run application A runs and fetch files like xml, xslt, xsd from other component B. We have recently upgraded to latest version of spring 5 and open jdk 11. I am facing file not found exceptions after version upgrade while running junit tests of A. We are setting user.dir to switch current directory but still it is trying to check in A's folder structure.
Uses following
System.setProperty("user.dir", systemUserDir + "/../ComponentB/src/main/resources");
then we have this property mentioned properties file that we append to above
TEST.Test.XSLTFile=document/business/Test.xslt
So it should ideally search in ComponentB path but it tries searching file in Component A path.
答案1
得分: 0
看 https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8202127,我认为你需要另一种设置资源查找目录的方法。
如果你能分享依赖于当前设置目录的代码,我可能能提供更多帮助。
英文:
Looking at the https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8202127 I think you'll need another way of setting a directory where the resources should be found.
I might be able to help some more if you would share code which relies on the current directory set.
专注分享java语言的经验与见解,让所有开发者获益!
评论