Это мое первое приложение на Spring. Использовал SpringBOOT, Maven, SpringMVC, Thymeleaf, SpringJPA, MySQL.
Подскажите пожалуйста, код нормально работает с методами предопределенными в интерфейсе Repository(CrudRepository или PagingAndSortingRepository), но когда пытаюсь создать свое query, то проект не компилируется с ошибкой:
Error creating bean with name 'itemRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property status found for type Item! Did you mean 'state'
ItemRepository.java
import com.heiko.to_do_list.model.Item;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface ItemRepository extends PagingAndSortingRepository<Item, Integer> {
List<Item> findByStatus(boolean stateVal);
}
ItemController.java
import com.heiko.to_do_list.model.Item;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@Controller
public class ItemController {
@Autowired
private ItemRepository dao;
private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
@RequestMapping(value = "/", method = RequestMethod.GET)
public String ListItems(Model model) {
model.addAttribute("items", dao.findAll());
return "items/list";
}
}
добавил в папку recources, spring-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
<repositories base-package="com.heiko.to_do_list.controller" />
</beans:beans>
не помогает.
Ссылка на GIT: Git