在控制器中找不到服务bean

时间:2017-09-06 21:00:20

标签: java spring applicationcontext

我有一项服务,我试图在我的控制器中自动装配。每次我构建应用程序时都会出现此错误。我知道我在应用程序环境中做错了什么。任何人都能解释一下吗?

这是关于git的项目:https://github.com/zackh321/spring-swag

的applicationContext.xml

<?xml version = "1.0" encoding = "UTF-8"?>

<beans xmlns = "http://www.springframework.org/schema/beans"
       xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation = "http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

  <bean id="triangleService" class="com.zmags.interview.service.triangle.TriangleService" abstract="true">
    <property name="triangleController" ref="triangleController"></property>
  </bean>


</beans>

错误:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'demoController' defined in file [/Users/zhyder/Desktop/springboot-swagger-test/spring-swag/target/classes/com/zmags/interview/controller/DemoController.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zmags.interview.controller.DemoController]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanIsAbstractException: Error creating bean with name 'triangleService': Bean definition is abstract

编辑appContext

<?xml version = "1.0" encoding = "UTF-8"?>

<beans xmlns = "http://www.springframework.org/schema/beans"
       xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation = "http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">

  <bean id="demoController" class="com.zmags.interview.controller.DemoController">
    <property name="triangleService" ref="triangleService"></property>
  </bean>

</beans>

0 个答案:

没有答案