0

I have a question how to inject values into implemented by spring class I don't want use xml to define that values like in this piece

<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> <property name="host" value="your.smtphost.com"/> <property name="port" value="25"/> <property name="username" value="yourusername"/> <property name="password" value="yourpassword"/> <property name="javaMailProperties"> <props> <!-- Use SMTP-AUTH to authenticate to SMTP server --> <prop key="mail.smtp.auth">true</prop> <!-- Use TLS to encrypt communication with SMTP server --> <prop key="mail.smtp.starttls.enable">true</prop> </props> </property> 

I would like to do it by annotation. I know there is method to extend that class but maybe there is another?

1 Answer 1

1

You can use annotation driven spring configuration for this as shown below

@Configuration class SpringConfiguration { @Bean public JavaMailSenderImpl mailSender(){ JavaMailSenderImpl object = new JavaMailSenderImpl(); object.setXXX(ABC); ..... return object; } } 
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! So if there are other possibilities and someone use something different not the xml configuration please share ;)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.