1

実際にはアクターであるSpringサービスがあり、情報を受け取りましたが、インジェクションが失敗したため、別のSpringサービスに渡すことができません。

@Service("mailContainer")
@Scope("prototype")
@Component
public class MailContainer extends UntypedActor {

    private final LoggingAdapter LOG = Logging.getLogger(getContext().system(), this);

    private Mail value;
    private List<Mail> mailList = new ArrayList<Mail>();
    private Integer size;

    @Autowired
    @Qualifier("springService")
    private SpringService springService;

    //@Autowired
    public void setSpringService(SpringService springService) {
        this.springService = springService;
    }

    public MailContainer(Mail value) {
        this.value = value;
    }

    @Override
    public void onReceive(Object message) throws Exception {

        //    LOG.debug("+ MailContainer message: {} ", message);
        if (message instanceof Mail) {
            value = (Mail) message;
            System.out.println("MailContainer get message with id   " + value.getId());
            System.out.println("With time   " + value.getDateSend());
            //getSender().tell(value, getSelf()); //heta uxarkum
            //this.saveIt(value);
            springService.add(value);
        }

    }

そしてセカンドサービス

@Service("springService")
//@Component
@Scope("session")
public class SpringService {

    private List<Mail> mailList = new ArrayList<Mail>();

    public void add(Mail mail) {
        System.out.println("Saving mail from Spring " +mail.getId());
        mailList.add(mail);

    }

    public List<Mail> getMailList() {

        return mailList;
    }

}

春の設定、これはakkaの春の例からのものです

@Configuration
//@EnableScheduling
//EnableAsync
@ComponentScan(basePackages = {"com"}, excludeFilters = {
    @ComponentScan.Filter(Configuration.class)})
//@ImportResource("classpath:META-INF/spring/spring-data-context.xml")
//@EnableTransactionManagement
//@EnableMBeanExport
//@EnableWebMvc
public class CommonCoreConfig {


 // the application context is needed to initialize the Akka Spring Extension
  @Autowired
  private ApplicationContext applicationContext;

  /**
   * Actor system singleton for this application.
   */
  @Bean
  public ActorSystem actorSystem() {
    ActorSystem system = ActorSystem.create("AkkaJavaSpring");
    // initialize the application context in the Akka Spring Extension
    SpringExtProvider.get(system).initialize(applicationContext);
    return system;
  }
}

では、どうすれば別のSpringサービスを注入できますか?????????

4

1 に答える 1