が動作していないが、私のUserRepositoryとfind関数この春データのクエリはここ
@Repository
public interface UserRepository extends CrudRepository<JPA_Users, Long> {
List<JPA_Users> findByName(String Name);
}
で、コントローラの機能の一つで、私は
@RequestMapping(value = "/jpadata1", method = RequestMethod.GET)
public String jpadata1(ModelMap map) {
UserRepository repository;
ApplicationContext context = new ClassPathXmlApplicationContext("beans1.xml");
repository = context.getBean(UserRepository.class);
Iterable usrs = repository.findByName("shahzad");
}
を次のようにこの機能を見つけるにアクセスしようとしていますデータベース内の名前付きの列を持つ列と私は値を持つ複数のレコードを持っているshahzadこれらのレコードはすべて返されると期待していたが、この関数は何も返さないレコードは返されない
Shahzad
実際には、基本となるSpringの基本概念を学ぶ必要があります。コンテキストとは何か、依存性注入などです。Spring Beanから新しいコンテキストを再作成してリポジトリを検索しますこの新しい文脈は完全に間違っています。 –