Java 设置bean属性时无法解析对bean的引用
在我第一次设置REST示例时,您能否帮助解决以下错误。 Tomcat 6启动时出现错误: 上下文初始化失败 org.springframework.beans.factory.BeanCreationException:错误 正在创建名为“restContainer”的bean:无法解析对的引用 设置bean属性“serviceBeans”时bean“probablyPrimeserive” 使用键[0];嵌套异常是 rg.springframework.beans.factory.NoSuchBean定义异常:否 已定义名为“ProbablyPrimeserive”的bean mybeans.xmlJava 设置bean属性时无法解析对bean的引用,java,spring,rest,cxf,Java,Spring,Rest,Cxf,在我第一次设置REST示例时,您能否帮助解决以下错误。 Tomcat 6启动时出现错误: 上下文初始化失败 org.springframework.beans.factory.BeanCreationException:错误 正在创建名为“restContainer”的bean:无法解析对的引用 设置bean属性“serviceBeans”时bean“probablyPrimeserive” 使用键[0];嵌套异常是 rg.springframework.beans.factory.NoSuch
<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>
====================================
Try@Silviu尝试了上述代码,但结果相同error@Senthil尝试添加@coder:现在尝试添加注释配置,但是没有相同的错误。如果您在xml中手动定义bean,它能工作吗?如果没有,那么xml内容就不是问题,是其他原因造成了问题(可能根本没有加载xml?)
@Service("probablyPrimeSerivce")
@Path("/prime")
public class ProbablyPrimeSerivce {
@GET
@Path("/{number}")
@Produces("text/plain")
public boolean isPrime(@PathParam("number") int number){
return true;
}
}