Java Spring没有类型匹配的bean。。。找到依赖项:至少需要1个bean

Java Spring没有类型匹配的bean。。。找到依赖项:至少需要1个bean,java,spring,spring-mvc,dependency-injection,autowired,Java,Spring,Spring Mvc,Dependency Injection,Autowired,我在匹配bean方面有困难。我的项目基于“行动中的春天”的项目 和servlet-context.xml <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure --> <!-- Enables the Spring MVC @Controller programming model --> <annotation-driven /&

我在匹配bean方面有困难。我的项目基于“行动中的春天”的项目

和servlet-context.xml

<!-- DispatcherServlet Context: defines this servlet's request-processing 
    infrastructure -->

<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />

<!-- Handles HTTP GET requests for /resources/** by efficiently serving 
    up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />

<!-- Resolves views selected for rendering by @Controllers to .jsp resources 
    in the /WEB-INF/views directory -->
<beans:bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <beans:property name="prefix" value="/WEB-INF/views/" />
    <beans:property name="suffix" value=".jsp" />
</beans:bean>



<context:component-scan base-package="com.kmazur.*" />
控制器

@Controller
@RequestMapping("/boards")
public class BoardController {

private static final String MAX_LONG_AS_STRING = "9223372036854775807";


private BoardRepository boardRepository;


@Autowired
public BoardController(BoardRepository boardRepository) {
    this.boardRepository = boardRepository;
}

我已经尝试以不同的方式添加adnotation,但错误总是一样的。

我会将回购更改为:

public interface BoardRepository extends JpaRepository<Board,Long>{
//Methods here
}
让Spring知道在哪里可以看到:

<jpa:repositories base-package="com.repositories" /> 


(如果BoardRepository是在com.repositories包中定义的)

我没有读过这本书,但它看起来像spring数据, .
他们还创建了没有IMT实现的接口。

BoardRepository的具体实现在哪里?如果你有一个,它是否有spring注释(比如@Component或@Repository)?我试图让它像书中那样,没有实现这个接口。另一方面,当我在带有注释的Board类中实现BoardRestory时,错误是相同的。在实现之后,我又出现了另一个错误org.springframework.beans.factory.beandDefinitionStoreException:解析来自ServletContext资源的XML文档时发生意外异常[/WEB-INF/spring/appServlet/servlet context.XML];嵌套的异常是java.lang.NoSuchMethodError:org.springframework.beans.factory.xml.XmlReaderContext.getEnvironment()Lorg/springframework/core/env/Environment;我通过向依赖项添加Springbean解决了这个问题,但当我尝试在服务器上运行project时,我只有404。
public class Board {
private final Long id;
private final String message;
private final Date time;
private Double latitude;
private Double longitude;
@Controller
@RequestMapping("/boards")
public class BoardController {

private static final String MAX_LONG_AS_STRING = "9223372036854775807";


private BoardRepository boardRepository;


@Autowired
public BoardController(BoardRepository boardRepository) {
    this.boardRepository = boardRepository;
}
public interface BoardRepository extends JpaRepository<Board,Long>{
//Methods here
}
@Autowired
private BoardRepository boardRepository;
<jpa:repositories base-package="com.repositories" />