UserRepository文件
package com.study.repository;
import com.study.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.NoRepositoryBean;
@NoRepositoryBean
public interface UserRepository extends JpaRepository {
User findById(long id);
Long deleteById(long id);
}
添加@NoRepositoryBean
注解,必须使用该注解标明,此接口不是一个Repository Bean 否则就会报上方的错误
把@NoRepositoryBean
注释掉后,应把它变成一个Repository Bean
UserRepository extends JpaRepository<User,Long>
package com.study.repository;
import com.study.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
//@NoRepositoryBean
public interface UserRepository extends JpaRepository<User,Long> {
User findById(long id);
Long deleteById(long id);
}
网友评论