如何更改JCS cache.ccf文件的路径? [英] How to change JCS cache.ccf file's path?

查看:211
本文介绍了如何更改JCS cache.ccf文件的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试大约一个小时更改cache.ccf文件的路径...
呼叫JCS.getInstance("myRegion");时出现此错误:

I'm trying to change path of cache.ccf file about an hour...
When I'm calling JCS.getInstance("myRegion"); I'm getting this error:

Exception in thread "main" java.lang.IllegalStateException: Failed to load properties for name [/cache.ccf]

我试图将cache.ccf放入src文件夹.在这种情况下,一切正常.但是我希望它在./config/目录中,而不是在./src目录中.我试图更改配置文件名:

I tried to put cache.ccf into src folder. In this case everything's OK. But I want it to be in ./config/ directory, not in ./src. I tried to change config file name:

JCS.setConfigFilename("../config/cache.ccf");

但是它不起作用,并且出现了相同的错误:

But it's not working and I'm getting the same error:

Exception in thread "main" java.lang.IllegalStateException: Failed to load properties for name [../config/cache.ccf]

它表明JCS试图在src目录中找到名为"../config/cache.ccf"的文件.
这里我发现了这句话:
类路径应包含此文件所在的目录,或者应将文件放置在类路径的根目录中,因为它是自动发现的.

It seams that JCS tries to find the file named "../config/cache.ccf" in src directory.
Here i found this sentence:
The classpath should include the directory where this file is located or the file should be placed at the root of the classpath, since it is discovered automatically.

但是即使cache.ccf文件位于项目的根目录中,我的应用程序也不起作用.
如何更改cache.ccf文件的路径?

But my applilcation don't work even if cache.ccf file is in the root directory of project.
How can I change cache.ccf file's path?

推荐答案

我遇到了这个问题-而且由于我的项目中有多个类加载器(axis2,tomcat),因此很难确定在哪里放入cache.ccf文件.我最终没有使用.properties文件并直接对其进行配置-这是我的操作方法...

I've had this problem - and because there's multiple class loaders around in my projects (axis2, tomcat), it can be pretty hard to figure out where to put the cache.ccf file. I ended up not using a .properties file and configuring it directly - here's how I did it...

CompositeCacheManager ccm = CompositeCacheManager.getUnconfiguredInstance();
Properties props = new Properties();

props.put("jcs.default","DC");
props.put("jcs.default.cacheattributes",
          "org.apache.jcs.engine.CompositeCacheAttributes");
// lots more props.put - this is basically the contents of cache.ccf

ccm.configure(props);
JCS sessionCache = JCS.getInstance("bbSessionCache");

这篇关于如何更改JCS cache.ccf文件的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆