小编Kam*_*iya的帖子

无法为CacheableOperation []缓存找到名为''的缓存

我的错误是:

Exception in thread "main" java.lang.IllegalArgumentException: Cannot find cache named 'getActionsBycasId' for CacheableOperation[public java.util.List com.codinko.database.DataBaseConnection.getActionsByCasId(int)] caches=[getActionsBycasId] | key='' | keyGenerator='' | cacheManager='' | cacheResolver='' | condition='' | unless=''
    at org.springframework.cache.interceptor.AbstractCacheResolver.resolveCaches(AbstractCacheResolver.java:81)
    at org.springframework.cache.interceptor.CacheAspectSupport.getCaches(CacheAspectSupport.java:214)
    at org.springframework.cache.interceptor.CacheAspectSupport$CacheOperationContext.<init>(CacheAspectSupport.java:553)
    at org.springframework.cache.interceptor.CacheAspectSupport.getOperationContext(CacheAspectSupport.java:227)
    at org.springframework.cache.interceptor.CacheAspectSupport$CacheOperationContexts.<init>(CacheAspectSupport.java:498)
    at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:299)
    at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:653)
    at com.codinko.database.DataBaseConnection$$EnhancerBySpringCGLIB$$21a0d8a.getActionsByCasId(<generated>)
    at com.codinko.caching.EmployeeDAO.getActionBycasId(EmployeeDAO.java:47)
    at com.codinko.caching.EmployeeDAO$$FastClassBySpringCGLIB$$191aa49b.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
    at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:649)
    at com.codinko.caching.EmployeeDAO$$EnhancerBySpringCGLIB$$3399d753.getActionBycasId(<generated>)
    at com.codinko.caching.Main.main(Main.java:22)    
Run Code Online (Sandbox Code Playgroud)

我的功能是:

@Cacheable("getActionsBycasId")
public List<SMSAction> getActionsByCasId(int casId){
    System.out.println("Inside getActionsByCasId");
    //My logic
    return list;
}    
Run Code Online (Sandbox Code Playgroud)

当我在ehcache.xml下面添加时,上面的错误没有来,但不知道为什么会出现这个错误.

<cache name="getActionsBycasId" maxElementsInMemory="50" eternal="false"
    overflowToDisk="false" memoryStoreEvictionPolicy="LFU" …
Run Code Online (Sandbox Code Playgroud)

spring ehcache

20
推荐指数
3
解决办法
3万
查看次数

理解Collection.isEmpty()和Collection.size()== 0之间的区别?

我已经阅读了很多关于isEmpty()size()0 之间的区别的文章,对于检查是否collection为空或者没有,并且发现isEmpty()有性能size()但我无法理解为什么性能isEmpty()良好即使内部isEmpty()只有size == 0?

我的问题是:

  1. 任何人都可以轻松解释哪种情况isEmpty()更快,以及何时使用isEmpty()size()功能检查是否collectionempty

  2. 任何人都可以使用代码或其他方式(图表,图表等)解释这一点,以便任何初学者都能轻松理解吗?

java size collections performance is-empty

9
推荐指数
2
解决办法
4351
查看次数

BeanPropertyRowMapper 在 spring 内部如何工作?

我知道当我触发查询时BeanPropertyRowmapper使用setter方法,select它使用getter方法吗?

我面临以下问题:

在中database,defaultPriority 在string但我想int在我的SMSActionpojo 类中设置值。

class SMSAction implements Serializable {

private int defaultPriority;

public int getDefaultPriority() {
    System.out.println("Inside getDefaultPriority()");
    return defaultPriority;
}

public void setDefaultPriority(String defaultPriority) {
    System.out.println("Inside setDefaultPriority(String defaultPriority)"+defaultPriority);

    if(defaultPriority.equalsIgnoreCase("L")){
        System.out.println("Condition");
        this.defaultPriority = 1;
    }
  }
}    
Run Code Online (Sandbox Code Playgroud)

这是我得到的错误:

Exception in thread "main" org.springframework.jdbc.UncategorizedSQLException: PreparedStatementCallback; uncategorized SQLException for SQL [select SMSACTIONID,SMSACTIONCODE,ACTIONDESC,CASID,DEFAULTPRIORITY from tblsmsaction]; SQL state [99999]; error code [17059]; Fail to convert …
Run Code Online (Sandbox Code Playgroud)

java database spring spring-mvc jakarta-ee

5
推荐指数
1
解决办法
1804
查看次数

在Spring中使用jdbctemplate进行Fire Sequence.nextval查询

数据库: Oracle

我有一个表,其中有10列,我想要插入行时序列下一个值,并使用插入的序列号.

现在我已经搜索并发现Spring的KeyHolder很有用,但仅限于少于8个字段,所以我不能使用它.

如何启动"select MySequence.nextval from dual"查询并获取序列jdbctemplate(NamedParameterJDBCTemplate)

是获得插入序列值的其他方法吗?

java database oracle spring jdbctemplate

5
推荐指数
2
解决办法
7659
查看次数

为什么我们不能在带有ehcache的spring中使用带有静态方法的@Cacheable?

我是新来的春天和阅读,我们不能使用@Cacheable带有static method但不能发现为什么我们不能用那么任何一个能解释让初学者也很容易理解?我们可以使用静态方法进行检索database table吗?我已经制作static methodservice layerDAO 的所有方法,所以这是thread-safe吗?

java spring caching ehcache

4
推荐指数
1
解决办法
3230
查看次数

如何解决java.lang.IllegalStateException:服务器处于错误状态异常

我正在尝试在核心java项目(swing应用程序)中部署restful web-service.我正在使用jersy.我已经搜索到谷歌的许多网站,但我无法找到为什么这附加.

public class Main { 
public static void main(String[] args) throws Exception{        
    ResourceConfig resourceConfig = new ResourceConfig(MyResource.class);
    URI baseUri = UriBuilder.fromUri("http://localhost/").port(10049).build();

    HttpServer server = JdkHttpServerFactory.createHttpServer(baseUri,resourceConfig);
    server.start();
    System.out.println("Press Enter to stop the server. ");
    System.in.read();
    server.stop(0);
}
}


@Path("/hello")
public class MyResource {

// This method is called if TEXT_PLAIN is request
@GET
@Produces(MediaType.TEXT_PLAIN)
public String sayPlainTextHello() {
    return "Hello Jersey";
}

// This method is called if XML is request
@GET
@Produces(MediaType.TEXT_XML)
public String sayXMLHello() {
    return "sdasd";
} …
Run Code Online (Sandbox Code Playgroud)

java rest exception-handling jersey httpserver

4
推荐指数
1
解决办法
6078
查看次数

MongoDB 聚合框架中将小数四舍五入到最接近的整数

我已经浏览了以下网站,但无法得到我的解决方案。 四舍五入到小数点后 2 位

我有以下小数并想四舍五入到最接近的整数:

34.56 => 35
34.67 => 35
34.12 => 34
Run Code Online (Sandbox Code Playgroud)

我已经尝试过这个:

            "$subtract": [
                        "$x",
                        { "$mod": ["$x", 1] }
                    ]
Run Code Online (Sandbox Code Playgroud)

与Oracle Round 函数相同

我可以在 MongoDB 中做什么?

rounding mongodb mongodb-query aggregation-framework

1
推荐指数
1
解决办法
2549
查看次数