Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 在Springboot+;JPA存储库_Spring Boot_Spring Data Jpa_Second Level Cache - Fatal编程技术网

Spring boot 在Springboot+;JPA存储库

Spring boot 在Springboot+;JPA存储库,spring-boot,spring-data-jpa,second-level-cache,Spring Boot,Spring Data Jpa,Second Level Cache,我对主表的二级缓存使用Spring引导配置。 我没有在Spring Boot中配置二级缓存。需要了解缓存是如何完成的以及检索 这是我的Application.java类(SpringBootServletilizer)。。我添加了一个测试方法allCodeValues(),以验证是否只触发了一次hibernate查询。但是我看到查询被触发了两次,因此说存储库调用没有缓存在hibernate中。请帮助我准确配置SpringBoot for EhCaching public class Applic

我对主表的二级缓存使用Spring引导配置。 我没有在Spring Boot中配置二级缓存。需要了解缓存是如何完成的以及检索

这是我的Application.java类(SpringBootServletilizer)。。我添加了一个测试方法allCodeValues(),以验证是否只触发了一次hibernate查询。但是我看到查询被触发了两次,因此说存储库调用没有缓存在hibernate中。请帮助我准确配置SpringBoot for EhCaching

public class Application extends SpringBootServletInitializer {
public static void main(String[] args) throws Exception{        

    SpringApplication.run(Application.class, args);      
}

@Autowired
WorkflowListRepository wflListRepo;

@Bean(name="getAllCodeValue")
public List<WorkFlowList> allcodeValues(){

    List<WorkFlowList> wflList= wflListRepo.getAllDocuments();

    wflList= wflListRepo.getAllDocuments();

    return wflList;
}
我使用JPARepository与实体沟通。。。在这里,我使用WorkfowRepository获取二级缓存中的数据

@Repository
public interface WorkflowListRepository extends JpaRepository<WorkFlowList, String>{


public List<WorkFlowList> getAllDocuments();
}
@存储库
公共接口WorkflowListRepository扩展了JpaRepository{
公共列表getAllDocuments();
}
在实体中,我添加了注释@Cacheable和@Cache,如下所示

@Entity
@Cacheable
@Cache(usage=CacheConcurrencyStrategy.READ_ONLY)
@Table(name = "WORKFLOW_LIST")
@Access(AccessType.FIELD)
@NamedQuery(name="WorkFlowList.getAllDocuments",query = "from WorkFlowList work")
public class WorkFlowList implements in.vit.leasing.generic.entity.Entity<WorkFlowList>{
.......
}
@实体
@可缓存
@缓存(用法=缓存并发策略。只读)
@表(name=“工作流列表”)
@访问权限(AccessType.FIELD)
@NamedQuery(name=“WorkFlowList.getAllDocuments”,query=“来自WorkFlowList工作”)
公共类工作流列表在.vit.leasing.generic.entity.entity中实现{
.......
}
这会有帮助吗?
@Entity
@Cacheable
@Cache(usage=CacheConcurrencyStrategy.READ_ONLY)
@Table(name = "WORKFLOW_LIST")
@Access(AccessType.FIELD)
@NamedQuery(name="WorkFlowList.getAllDocuments",query = "from WorkFlowList work")
public class WorkFlowList implements in.vit.leasing.generic.entity.Entity<WorkFlowList>{
.......
}