错误 未找到类型为com.gridsearch.entities.Film
的属性我的资料库
package com.gridsearch.repository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.CrudRepository;
import com.gridsearch.entities.Film;
public interface FilmRepository extends CrudRepository<Film,Short>{
public Page<Film> findAll(Pageable page);
public Film findOne(short Id);
}
我的服务
package com.gridsearch.service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import com.gridsearch.entities.Film;
public interface FilmService {
public Page<Film> allFilms(Pageable page);
public Film findOne(int Id);
}
我的服务实施
package com.gridsearch.service;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import com.gridsearch.entities.Film;
import com.gridsearch.repository.FilmRepository;
@Repository
public class FilmServiceImpl implements FilmService{
@Autowired
private FilmRepository repository;
@Transactional
public Page<Film> allFilms(Pageable page) {
return repository.findAll(page);
}
@Override
public Film findOne(int id) {
return repository.findOne((short) id);
}
}
答案 0 :(得分:7)
应该是Short
而不是short
:
public Film findOne(Short Id);
顺便说一下,你可以简单地扩展已经提供方法PagingAndSortingRepository
的{{1}}:
findAll(Pageable page)
答案 1 :(得分:2)
我知道这个问题已得到解答,但我遇到了同样的问题,因为我在我的存储库中留下了一个旧方法,如
public List<Entity> findByDateBetween(Long a, Long b)
而“date”列在我的数据库中不再存在。