Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use @autowired in web process

  • Loading branch information...
commit 88dfb8f285dea3a980d065e6d6142d38b8443d5c 1 parent b05287f
@ryanbrainard ryanbrainard authored
View
8 web/src/main/java/com/heroku/devcenter/BigOperationWebController.java
@@ -2,8 +2,7 @@
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.amqp.core.Queue;
-import org.springframework.context.ApplicationContext;
-import org.springframework.context.annotation.AnnotationConfigApplicationContext;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -20,9 +19,8 @@
public class BigOperationWebController {
// load RabbitMQ configuration provided by Spring
- private final ApplicationContext rabbitConfig = new AnnotationConfigApplicationContext(RabbitConfiguration.class);
- private final AmqpTemplate amqpTemplate = rabbitConfig.getBean(AmqpTemplate.class);
- private final Queue rabbitQueue = rabbitConfig.getBean(Queue.class);
+ @Autowired private AmqpTemplate amqpTemplate;
+ @Autowired private Queue rabbitQueue;
@ModelAttribute("bigOp")
public BigOperation newBigOp() {
Please sign in to comment.
Something went wrong with that request. Please try again.