从同一个bean的另一个方法调用缓存方法时,Spring缓存不起作用.
这是一个以清晰的方式解释我的问题的例子.
组态:
<cache:annotation-driven cache-manager="myCacheManager" />
<bean id="myCacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager">
<property name="cacheManager" ref="myCache" />
</bean>
<!-- Ehcache library setup -->
<bean id="myCache"
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:shared="true">
<property name="configLocation" value="classpath:ehcache.xml"></property>
</bean>
<cache name="employeeData" maxElementsInMemory="100"/>
Run Code Online (Sandbox Code Playgroud)
缓存服务:
@Named("aService")
public class AService {
@Cacheable("employeeData")
public List<EmployeeData> getEmployeeData(Date date){
..println("Cache is not being used");
...
}
public List<EmployeeEnrichedData> getEmployeeEnrichedData(Date date){
List<EmployeeData> employeeData = getEmployeeData(date);
...
}
}
Run Code Online (Sandbox Code Playgroud)
结果:
aService.getEmployeeData(someDate);
output: Cache is not being used
aService.getEmployeeData(someDate);
output:
aService.getEmployeeEnrichedData(someDate);
output: Cache is not being used
Run Code Online (Sandbox Code Playgroud)
该getEmployeeData方法调用使用缓存employeeData …
有没有使用Python从RESTful服务获取JSON数据的标准方法?
我需要使用kerberos进行身份验证.
一些片段会有所帮助.
如何在Perl中将字符串转换为数字?
例:
$str = '10.0500000';
$number = $str * 1; # 10.05
Run Code Online (Sandbox Code Playgroud)
还有另一种标准方法可以从'10 .0500000'获得10.05而不是乘以1吗?
当我将项目移动到java7时,Drools在init进程中开始抛出RuntimeDroolsException异常.当我进一步挖掘时,我发现当它验证java方言时会发生这种情况.
问题是:Drools 5.1.1将"java.version"系统属性与LANGUAGE_LEVELS进行比较以验证它.LANGUAGE_LEVELS是直到1.6的java版本的硬编码列表
In org.drools.rule.builder.dialect.java.JavaDialectConfiguration,
public static final String[] LANGUAGE_LEVELS = new String[]{"1.5", "1.6"};
Run Code Online (Sandbox Code Playgroud)
我不想改变源代码.所以我添加了以下作为绕过java方言验证的解决方法.
Properties properties = new Properties();
properties.setProperty( "drools.dialect.java.compiler.lnglevel","1.6" );
PackageBuilderConfiguration cfg =
new PackageBuilderConfiguration( properties );
KnowledgeBuilder knowledgeBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(cfg);
Run Code Online (Sandbox Code Playgroud)
除了编辑源代码之外,还有更好的方法吗?
PS:Drools 5.1.1是drools的最新生产版本
这是一个例子;
我有数字列表(1,5,8,36),我希望这些值作为(临时)表行.其中一种方法如下
select 1 as n into ##temp
union
select 5 as n
union
select 8 as n
union
select 36 as n
Run Code Online (Sandbox Code Playgroud)
问题是数字列表是动态的.它可以没有任何价值观.所以我需要一种适当的系统方法将这些值转换为临时表行.
谷歌番石榴是否有任何等效的apache commons'CollectionUtils.isEmpty(list)检查集合是否为空或空?
有没有更好的方法在SQL中编写像IN子句这样的表达式?
int x;
if (x == 1 || x == 2 || x ==3 || x == 4 ...)
{
//Doing something useful
}
Run Code Online (Sandbox Code Playgroud)
我想写下面的内容:
if (x in (1,2,3,4,...)) {}
Run Code Online (Sandbox Code Playgroud) 我有字符串列email_id; 数据看起来像这样:
email_id
"1"
"6"
"3 4"
"8"
"0 3"
"0 5 7"
Run Code Online (Sandbox Code Playgroud)
我想得到整数列表的ID.如果我的字符串中有两个数字,我想要最后一个.我的结果应该是这样的;
SELECT some_function (email_id ) FROM table
1
6
4
8
3
7
Run Code Online (Sandbox Code Playgroud)
是否可以在SQL Server中执行此操作?
java ×4
expression ×2
sql ×2
sql-server ×2
apache ×1
caching ×1
drools ×1
ehcache ×1
function ×1
guava ×1
if-statement ×1
java-7 ×1
json ×1
kerberos ×1
perl ×1
python ×1
rest ×1
rule-engine ×1
spring ×1
temp-tables ×1