This is my first Spring app. Used SpringBOOT, Maven, SpringMVC, Thymeleaf, SpringJPA, MySQL.
Please tell me the code works fine with methods predefined in the Repository interface (CrudRepository or PagingAndSortingRepository), but when I try to create my query, the project does not compile with an error:
Error creating bean with name 'itemRepository': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property found! 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"; } } added to the recources folder, 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> Does not help.
GIT Link: Git