我刚刚通过阅读《Spring Boot in Action》一书开始学习Spring Boot,并且正在学习本书的示例,尝试自己运行它们,但是使用时遇到了问题JpaRepository.findOne()。我遍历了本章以查找可能的不匹配之处。但是,它根本不起作用。该项目应该是一个简单的阅读清单。这是代码:Jpa界面:package com.lixin.readinglist;import org.springframework.data.jpa.repository.JpaRepository;/** * @author lixin */public interface ReaderRepository extends JpaRepository<Reader, String> {}SecurityConfig:package com.lixin.readinglist;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.context.annotation.Configuration;import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;import org.springframework.security.config.annotation.web.builders.HttpSecurity;import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;import org.springframework.security.core.userdetails.UserDetailsService;/** * @author lixin */@Configuration@EnableWebSecuritypublic class SecurityConfig extends WebSecurityConfigurerAdapter { private final ReaderRepository readerRepository; @Autowired public SecurityConfig(ReaderRepository readerRepository) { this.readerRepository = readerRepository; }而且我不断收到此错误:Error:(40, 86) java: method findOne in interface org.springframework.data.repository.query.QueryByExampleExecutor<T> cannot be applied to given types; required: org.springframework.data.domain.Example<S> found: java.lang.String reason: cannot infer type-variable(s) S (argument mismatch; java.lang.String cannot be converted to org.springframework.data.domain.Example<S>)
添加回答
举报
0/150
提交
取消