【发布时间】:2014-07-09 07:57:30
【问题描述】:
我有一个 maven/spring-mvc 应用程序,它是一个非常简单的 web 应用程序,它调用 mvc 控制器,它调用 web 服务来获取数据并将数据提供给 JSP。
我在 Eclipse 上的 Windows 机器上开发了这个应用程序。该应用程序执行得非常好。 我还通过命令提示符执行了“maven clean install”并创建了一个war文件并在windows上的tomcat 6和tomcat 7上手动部署,这也很好用。
现在我将同一个war文件移动到linux,它在catalina.out(tomcat日志)中给出了这个错误
`Caused by: org.springframework.beans.factory.BeanCreationException:
Could not autowire field: com.mondia.entertainment.ws.SecurityServer
com.mondia.common.controller.HomeController.security;
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No matching bean of type [com.mondia.entertainment.ws.SecurityServer] found for dependency:
expected at least 1 bean which qualifies as autowire candidate for this dependency.
Dependency annotations:
{@org.springframework.beans.factory.annotation.Autowired(required=true)}`
我的 mvc-dispatcher-servlet.xml 看起来像这样: `
<bean
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:application.properties" />
</bean>
<!-- enable @Autowired, @Required, @Resource (JSR-250) and other annotations -->
<context:annotation-config />
<context:component-scan base-package="com.mondia.entertainment" />
<context:component-scan base-package="com.mondia.common" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/pages/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<jaxrs:client id="securityClient"
serviceClass="com.mondia.entertainment.ws.SecurityServer" address="http://localhost:8080/restful-service/security">
<jaxrs:features>
<cxf:logging/>
</jaxrs:features>
</jaxrs:client>`
我什至将 apache-tomcat 7 文件夹(带有 war 文件)从 windows 移动到 linux 并尝试启动服务器,但我得到了同样的异常。
- 这个错误意味着什么?
- 为什么在我的 Windows 系统上的同一个 tomcat 实例上不会出现此错误?
【问题讨论】:
-
localhost:8080/restful-service/security 这个网址是否已启动并正在运行。如果失败,则可能永远不会创建 securityClient bean,因此会出现异常。
-
是的,所有的 URL 都可以正常工作。
标签: java linux spring maven tomcat