Java 使用JPA的Spring缓存
我试图缓存一些DAO调用,以提高spring缓存的性能,但它对我不起作用。请在下面找到我尝试过的代码 主要类别:Java 使用JPA的Spring缓存,java,spring,spring-boot,spring-data-jpa,spring-cache,Java,Spring,Spring Boot,Spring Data Jpa,Spring Cache,我试图缓存一些DAO调用,以提高spring缓存的性能,但它对我不起作用。请在下面找到我尝试过的代码 主要类别: @SpringBootApplication @EnableCaching @EnableAutoConfiguration public class Test{ public static void main(String[] args) { SpringAp
@SpringBootApplication
@EnableCaching
@EnableAutoConfiguration
public class Test{
public static void main(String[] args) {
SpringApplication.run(Test.class, args);
}
}
服务类别:
刀类
@Repository
public interface IProjectRepository extends BaseRepository<Project> {
Project findByName(@Param("projectName") String name);
}
格雷德尔先生
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version:2.2.0.RELEASE
compile group: 'org.springframework.boot', name: 'spring-boot-starter-parent', version:'2.2.0.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter', version: "2.0.4.RELEASE"
compile group: 'org.springframework.boot', name: 'spring-boot-starter-cache', version: '2.2.0.RELEASE'
它总是在控制台中打印“ProjectCache called”
请有人在这方面帮助我您需要添加spring上下文或spring上下文支持依赖项well@Ravik添加后,它也不工作,您是否调用
validateProject(字符串资源){
在同一个类中?您是否也可以在调用的validateProject的位置编写代码ProjectService@PrashanthS所以,处理任何注释时,都必须通过代理进行传递,以防,若您调用类的同一个方法,它将不会通过代理,并且注释处理器将不会出现在图片中来处理任何注释,无论它是可计算的/自定义注释或任何内容。您需要添加spring上下文或spring上下文支持依赖项作为well@Ravik添加后,它也不工作,您是否调用validateProject(字符串资源){
在同一个类中?您是否也可以在调用的validateProject的位置编写代码ProjectService@PrashanthS所以,处理任何注释时,都必须通过代理进行传递,以防,若您调用类的同一个方法,它将不会通过代理,并且注释处理器将不会出现在图片中来处理任何注释,无论它是可计算的/自定义注释或任何东西。
@Entity
@Table(name = "project")
@Data
@EqualsAndHashCode
public class Project implements Serializable, ICommonEntity {
private static final long serialVersionUID = 1L;
@Id
private Integer id;
private String name;
}
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version:2.2.0.RELEASE
compile group: 'org.springframework.boot', name: 'spring-boot-starter-parent', version:'2.2.0.RELEASE'
compile group: 'org.springframework.boot', name: 'spring-boot-starter', version: "2.0.4.RELEASE"
compile group: 'org.springframework.boot', name: 'spring-boot-starter-cache', version: '2.2.0.RELEASE'