设置bean属性时无法解析对bean的引用

时间:2014-08-01 03:38:14

标签: java spring rest cxf

您是否可以帮助解决以下错误,因为我是第一次设置REST示例。 我在Tomcat 6启动时遇到错误严重:

  

上下文初始化失败   org.springframework.beans.factory.BeanCreationException:错误   创建名称为' restContainer':无法解析引用的bean   bean可能是PremeSerivce'在设置bean属性' serviceBeans'   用键[0];嵌套异常是   rg.springframework.beans.factory.NoSuchBeanDefinitionException:没有   bean命名为“mightPrimeSerivce'已定义

我的beans.xml

  <beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:context="http://www.springframework.org/schema/context"
  xmlns:jaxrs="http://cxf.apache.org/jaxrs"
  xmlns:cxf="http://cxf.apache.org/core" 
  xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  http://cxf.apache.org/jaxrs 
  http://cxf.apache.org/schemas/jaxrs.xsd 
  http://cxf.apache.org/core 
  http://cxf.apache.org/schemas/core.xsd
  http://www.springframework.org/schema/context
  http://www.springframework.org/schema/context/spring-context.xsd"> 

  <import resource="classpath:META-INF/cxf/cxf.xml"/> 
  <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/> 


   <context:component-scan base-package="com" />


  <jaxrs:server id="restContainer" address="/"> 
    <jaxrs:serviceBeans> 
    <ref bean="probablyPrimeSerivce"/> 
    </jaxrs:serviceBeans> 
 </jaxrs:server> 


</beans> 

=============================================== =

My ProbablyPrimeSerivce类

@Service("probablyPrimeSerivce")
@Path("/prime")
public class ProbablyPrimeSerivce {

@GET
@Path("/{number}")
@Produces("text/plain")
public boolean  isPrime(@PathParam("number") int number){
    return true;
}
}

====================================

enter image description here

0 个答案:

没有答案