I have a project with spring-config.xml I have something like this:
<!-- Job & Stage status notification via email-->
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="${smtp.host}"/>
<property name="port" value="${smtp.port}"/>
<property name="username" value="${smtp.username}"/>
<property name="password" value="${smtp.password}"/>
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true</prop>
<prop key="mail.transport.protocol">smtp</prop>
<prop key="mail.smtp.starttls.enable">true</prop>
</props>
</property>
</bean>
In an existing class I have something like this:
@Autowired
private StatusEmailSender emailSender;
This seems to work. When I put the same code snippet in my own classes, emailSender
is null. I can't find any dependencies that I am missing. Any idea how to do this? My classes are in a separate module from the one in which this works. Any idea how I can tell Spring I want to use that bean?