我在Project B中有一个引用Project A中的Java的mule流。这些项目的结构如下。
Project A
src/test/java-ComponentClass
src/test/resources- propertyfile.properties
Project B(Mule project)
src/main/app(Flows)- testflow(flow with component referencing ComponentClass)
src/main/resources - propertyfile.propertiestestFlow以以下方式创建组件类bean。
<spring:beans>
<spring:bean id="beanA" class="com.packagename.ComponentClass"/>
</spring:beans>下面的段显示了ComponentClass如何访问属性文件。
propFilePath="src/test/resources/propertyfile.properties"
File propFile = new File(propFilePath);
if(!propFile.exists())// To handle mule flow as mule doesnt bundle src/test/resources
{
propFilePath=this.getClass().getResource("/propertyfile.properties");
// points to /usr/local/mule/mule-enterprise-standalone-3.6.0-M2/apps/ProjectB-1.0-SNAPSHOT/classes/propertyfile.properties -for standalone.- 1
//propFilePath="propertyfile.properties". <--eclipse-mule plugin-2
}
//process the file from its path-- Project A的编译方式使其测试类可以访问。Project B通过其pom从Project A导入测试jar。
现在,当我试图在构建项目之后,通过我的系统上的骡子独立运行流程时。该项目无法部署在骡子上,抛出一个嵌套的异常,propertyfile丢失了,因此ComponentClass的bean创建失败了。但是,在检查1-(在zip中)中的路径位置时,我发现文件实际上存在于类文件夹中。有什么想法发生了什么,我怎么能解决它?
另外,当我将文件放置在ProjectB的基本文件夹中并提供路径时,如行-2,当我在eclipse中从骡子运行时运行项目时,似乎没有任何问题,但是当我尝试部署到独立运行时时,这就失败了。
如有任何反馈或建议,将不胜感激。
发布于 2014-12-13 12:18:56
无论如何,骡子利用一个超自然的类路径故意隔离应用程序,以减少冲突。请阅读这个文档,以更好地理解它。
如果您所拥有的是某种共享的实用程序,那么为什么不只是创建一个创建jar的公共项目,然后让两个项目都依赖它呢?
https://stackoverflow.com/questions/27454741
复制相似问题