Spring boot &引用;处理程序调度失败;嵌套异常为NoClassDefFoundError:org/springframework/transaction/support/TransactionSynchronizationManager“;,

Spring boot &引用;处理程序调度失败;嵌套异常为NoClassDefFoundError:org/springframework/transaction/support/TransactionSynchronizationManager“;,,spring-boot,ehcache,hibernate-validator,Spring Boot,Ehcache,Hibernate Validator,我不熟悉弹簧靴。正在尝试实现ehcache,但出现以下错误: Handler dispatch failed; nested exception is NoClassDefFoundError: org/springframework/transaction/support/TransactionSynchronizationManager <cache name="nearestAirport" eternal="false" maxElementsInMemory="250"

我不熟悉弹簧靴。正在尝试实现ehcache,但出现以下错误:

Handler dispatch failed; nested exception is NoClassDefFoundError: org/springframework/transaction/support/TransactionSynchronizationManager
<cache name="nearestAirport" eternal="false"
    maxElementsInMemory="250" overflowToDisk="false" diskPersistent="false"
    timeToIdleSeconds="21600" timeToLiveSeconds="21600"
    memoryStoreEvictionPolicy="LRU" />
没有记录任何内容,只有调试语句

2018-05-30 14:09:47.291 DEBUG 5520 --- [nio-9091-exec-2] .m.m.a.ExceptionHandlerExceptionResolver : Resolving exception from handler [public org.springframework.http.ResponseEntity<?> com.jetblue.api.controller.AirportLocationController.getAirport(com.jetblue.api.domain.Location,org.springframework.validation.BindingResult)]: org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/transaction/support/TransactionSynchronizationManager
2018-05-30 14:09:47.293 DEBUG 5520 --- [nio-9091-exec-2] o.s.b.f.s.DefaultListableBeanFactory     : Returning cached instance of singleton bean 'customizedResponseEntityExceptionHandler'
<cache name="nearestAirport" eternal="false"
    maxElementsInMemory="250" overflowToDisk="false" diskPersistent="false"
    timeToIdleSeconds="21600" timeToLiveSeconds="21600"
    memoryStoreEvictionPolicy="LRU" />
服务层:

@Override
    public NearByAirport getAirport(Location location) {
       ............
}
<cache name="nearestAirport" eternal="false"
    maxElementsInMemory="250" overflowToDisk="false" diskPersistent="false"
    timeToIdleSeconds="21600" timeToLiveSeconds="21600"
    memoryStoreEvictionPolicy="LRU" />
接口:

public interface IAirportLocatorService {

    /**
     * Gets the airport.
     *
     * @param airport the airport
     * @return the airport
     */
    @Cacheable(value="nearestAirport", key="#location.latAndLong")
    public NearByAirport getAirport(Location location);

}
<cache name="nearestAirport" eternal="false"
    maxElementsInMemory="250" overflowToDisk="false" diskPersistent="false"
    timeToIdleSeconds="21600" timeToLiveSeconds="21600"
    memoryStoreEvictionPolicy="LRU" />
ehcache.xml

<cache name="nearestAirport" eternal="false"
    maxElementsInMemory="250" overflowToDisk="false" diskPersistent="false"
    timeToIdleSeconds="21600" timeToLiveSeconds="21600"
    memoryStoreEvictionPolicy="LRU" />

<cache name="nearestAirport" eternal="false"
    maxElementsInMemory="250" overflowToDisk="false" diskPersistent="false"
    timeToIdleSeconds="21600" timeToLiveSeconds="21600"
    memoryStoreEvictionPolicy="LRU" />

<cache name="nearestAirport" eternal="false"
    maxElementsInMemory="250" overflowToDisk="false" diskPersistent="false"
    timeToIdleSeconds="21600" timeToLiveSeconds="21600"
    memoryStoreEvictionPolicy="LRU" />
我尝试将@cacable注释放在服务层而不是服务层上,但结果是相同的。
任何指点都将不胜感激。谢谢。

我想你的问题是
cacheManager.setTransactionware(true)。这将导致Spring将缓存链接到事务(使用XA或其伪版本,对此我不确定)。因此,如果事务回滚,对缓存的修改也将被删除

<cache name="nearestAirport" eternal="false"
    maxElementsInMemory="250" overflowToDisk="false" diskPersistent="false"
    timeToIdleSeconds="21600" timeToLiveSeconds="21600"
    memoryStoreEvictionPolicy="LRU" />

但是您当前没有使用Spring事务管理器,因为它不在您的类路径中。所以春天不快乐。正在执行
cacheManager.setTransactionware(false)应该可以解决问题。

依赖项:1)org.springframework.boot:spring boot starter web 2)org.springframework.boot:spring boot starter cache 3)net.sf.ehcache:ehcache:2.10.4Dear Henri,谢谢您的时间,但我似乎已经完成了您在配置类中建议的操作:(.还有什么你能弄明白的吗?Arg…我是说SetTransactionWare(false)
<cache name="nearestAirport" eternal="false"
    maxElementsInMemory="250" overflowToDisk="false" diskPersistent="false"
    timeToIdleSeconds="21600" timeToLiveSeconds="21600"
    memoryStoreEvictionPolicy="LRU" />