Java SpringEhcache未被使用
Java SpringEhcache未被使用,java,spring-mvc,caching,ehcache,spring-cache,Java,Spring Mvc,Caching,Ehcache,Spring Cache,@DynamoDBTable(tableName="ProcessedDocuments") public class ProcessedDocument implements Serializable { //Just contains some simple get and set methods. } 我正在尝试为我的MVC页面设置一个简单的Spring缓存。但缓存似乎从未被使用过。每次都会执行我的函数 @Cacheable(value="newsDocuments",key="#cat
@DynamoDBTable(tableName="ProcessedDocuments")
public class ProcessedDocument implements Serializable {
//Just contains some simple get and set methods.
}
我正在尝试为我的MVC页面设置一个简单的Spring缓存。但缓存似乎从未被使用过。每次都会执行我的函数
@Cacheable(value="newsDocuments",key="#category")
public List<ProcessedDocument> getDocuments(String category, int limit){
List<ProcessedDocument> list = new ArrayList<ProcessedDocument>();
System.out.println("getDocumetns!" + DateTime.now());
list = getDBStuff(category,limit);
return list;
}
@DynamoDBTable(tableName="ProcessedDocuments")
public class ProcessedDocument implements Serializable {
//Just contains some simple get and set methods.
}
每次执行getDocuments时,它都会调用db并在控制台中输出一个新的“getDocumetns!”+DateTime.now()
@DynamoDBTable(tableName="ProcessedDocuments")
public class ProcessedDocument implements Serializable {
//Just contains some simple get and set methods.
}
我在调试中看到的唯一“奇怪”是
@DynamoDBTable(tableName="ProcessedDocuments")
public class ProcessedDocument implements Serializable {
//Just contains some simple get and set methods.
}
DEBUG: net.sf.ehcache.config.ConfigurationHelper - CacheDecoratorFactory not configured. Skipping for 'newsDocuments'.
DEBUG: net.sf.ehcache.config.ConfigurationHelper - CacheDecoratorFactory not configured for defaultCache. Skipping for 'newsDocuments'.
INFO : org.springframework.web.servlet.DispatcherServlet - FrameworkServlet 'mvc-dispatcher': initialization completed in 875 ms
我是不是错过了一些基本的东西?我找了你,用谷歌搜索了一下。我从Mkyong Ehcache的例子中找到了一个例子
@DynamoDBTable(tableName="ProcessedDocuments")
public class ProcessedDocument implements Serializable {
//Just contains some simple get and set methods.
}
@DynamoDBTable(tableName="ProcessedDocuments")
public class ProcessedDocument implements Serializable {
//Just contains some simple get and set methods.
}
我认为这对你很有用。因为您的ehcache.xml:不相似
Mkyong的示例ehcache.xml
@DynamoDBTable(tableName="ProcessedDocuments")
public class ProcessedDocument implements Serializable {
//Just contains some simple get and set methods.
}
我希望它会对你有用。我找了你,用谷歌搜索了一下。我从Mkyong Ehcache示例中找到了一个示例
@DynamoDBTable(tableName="ProcessedDocuments")
public class ProcessedDocument implements Serializable {
//Just contains some simple get and set methods.
}
@DynamoDBTable(tableName="ProcessedDocuments")
public class ProcessedDocument implements Serializable {
//Just contains some simple get and set methods.
}
我认为这对你很有用。因为您的ehcache.xml:不相似
Mkyong的示例ehcache.xml
@DynamoDBTable(tableName="ProcessedDocuments")
public class ProcessedDocument implements Serializable {
//Just contains some simple get and set methods.
}
我希望它对您有用。显示缓存的配置,您的配置中是否有
@EnableCaching
?(或者使用xml时使用
)。您好,是的,我确实使用注释驱动。不要将代码添加为注释,将其添加到问题中。从这里看,您只有缓存设置,与启用@Cacheable
无关。我应该在哪里添加启用缓存?我的印象是EnableCaching用于Spring应用程序而不是网站。您不是在构建Spring应用程序吗?如果您使用的是spring缓存注释,那么没有处理器的注释将无所作为。所以注册它。显示缓存的配置,您的配置中是否有@EnableCaching
?(或者使用xml时使用
)。您好,是的,我确实使用注释驱动。不要将代码添加为注释,将其添加到问题中。从这里看,您只有缓存设置,与启用@Cacheable
无关。我应该在哪里添加启用缓存?我的印象是EnableCaching用于Spring应用程序而不是网站。您不是在构建Spring应用程序吗?如果您使用的是spring缓存注释,那么没有处理器的注释将无所作为。那就注册吧。
@DynamoDBTable(tableName="ProcessedDocuments")
public class ProcessedDocument implements Serializable {
//Just contains some simple get and set methods.
}