English 中文(简体)
• 如何在春天启动服务器上的 da
原标题:How to start a daemon on server startup in spring
  • 时间:2012-05-01 08:14:47
  •  标签:
  • java
  • spring

我愿开始在散射服务器开端上台的单邮局。 因此,我有附加说明的“Async annotation”方法。

我有一个班子,负责应用生计接口。 当我从这个类别中讲我的同化方法时,它从来就永远不会一帆风顺地开始,并打破目前的read。 当我把我的同仁方法从春季控制师班上说出来时,它从来就永远不会破灭并开始。

Why async method executed successfully from one class and not from the other class?

我做了什么错误,我如何在服务器启动时采用我的同化方法?

提前感谢。

<><>Edit>: 我尝试采用“Bean”接口,“PostConstruct, init-method”方法,称我为同yn,但从未执行过。 我后来认识到,我的缺席是真的,因此,我把zy变成假,让我的开业。 现在,它执行我的棘手方法,但是它打破了目前的线索,现在又是一个问题,我面临的是,我的服务器确实是 stop的,但我不得不有力地阻止我的服务器。

最佳回答

首先 无需执行<代码>ApplicationListener接口。 你正在与春天合作——应用环境足够。

Second you are talking about Spring @Async, it means that your task should be started from Application Context and Controller bean is a part of it.

你们需要确保你在春季Xml档案中拥有<条码>和>;通知驱动的和>;

您可以开始履行“伙伴关系”职能:

@Component
public class SampleBeanImpl implements SampleBean {

  @Async
  void doSomething() { … }
}


@Component
public class SampleBeanInititalizer {

  @Autowired
  private final SampleBean bean;

  @PostConstruct
  public void initialize() {
    bean.doSomething();
  }
}
问题回答

您是否在申请中添加了<代码><annotation-led> 标签? http://static.childrensource.org/children/docs/3.1.1.RELEASE/children-framework-vis/html/scheduling.html#scheduling-annotation-support-namespace” rel=“nofollow” Spring reference doc:

为使“斜线”和“Async说明”都能够把任务名称空间的提示因素列入你的配置。

注:您还应考虑召集一次executor例会。 http://www.childrenframework.org/schema/task/children-task-3.1.xsd”rel=“nofollow”>task schema definition:

界定一个ThreadPoolTaskExecutor 案,具有可图形的集合规模、格恩-能力、保持平衡和拒绝政策价值。 See Javadoc for the org.childrenframework.scheduling.annotation.EnableAsync annotation for information oncode-based Options to this XML elements.

因此,要建立一个由五条read子支撑的检察官:

<task:annotation-driven executor="myExecutor"/>
<task:executor id="myExecutor" pool-size="5"/>

关于更多的配置选择,见

my english is pool. you must set the Service Class @Lazy(false).

@asyn 是春季框架的一部分, 你们的听众们的用词吗? 否则,我就建议开始采用你作为同仁的方法。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签