【发布时间】:2014-08-29 22:19:41
【问题描述】:
我为spring设置了一个应用配置文件,将其添加到facets中,并根据另一个完美运行的配置文件进行设置。 所有对 spring 组件的引用都是可见的并且似乎可以工作,但是对 xml 文件中的项目的所有引用都找不到。
一个例子是任务:
<task:scheduler id="taskScheduler" />
<task:executor id="taskExecutor" pool-size="1" />
<task:annotation-driven executor="taskExecutor" scheduler="taskScheduler" />
taskScheduler 和 taskExecutor 都无法解析。结果,任务 bean 永远不会设置,所以我所有的 @Scheduled 注释都不会工作。
为服务设置工厂提供者工作正常(所有@Service 和@Autowired 注释都有效),所以我完全确定问题出在项目中的一些配置问题上。
还需要在 IntelliJ 中配置哪些 bean 才能工作?为什么spring不重新扫描文件来查找对bean的引用?
这里是所有 springframework bean 的引用:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache.xsd"
default-lazy-init="true">
【问题讨论】:
-
你遇到了什么错误?
-
错误是“taskScheduler 和 taskExecutor 都无法解决”,所以所有计划任务都不起作用。在 spring.xml 中引用另一个 bean 的其他 bean 都不起作用。
标签: java spring intellij-idea