0

我正在从下面的链接运行示例:

http://chathurangat.blogspot.se/2011/12/send-email-in-spring-with-gmail.html

它工作正常。我的问题是为什么

ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("emailConfiguration.xml");
EmailSender emailSender=(EmailSender)context.getBean("emailSenderBean");

被放置在控制器中?有没有更好的读取xml文件的方法?并创建 bean?

ClassPathXmlApplicationContext 可以自动装配吗?

如何将此示例与 JPA 一起使用?

谢谢

4

1 回答 1

0

解决了

只需使用

那么你就不需要在控制器中使用 bean 的声明了。

谢谢

于 2013-11-28T20:07:27.537 回答